visual studio code 远程python解释器 visual studio code 远程开发_docker

OK, that's a little clickbaity but it's surely impressed the heck out of me. You can read more about VS Code Remote Development (at the time of this writing, available in the VS Code Insiders builds) but here's a little on my first experience with it.

好吧,这有点点击率,但肯定让我印象深刻。 您可以阅读有关VS Code远程开发的更多信息(在撰写本文时,可以在VS Code Insiders版本中找到),但这是我的第一次使用经验。

The Remote Development extensions require Visual Studio Code Insiders.

远程开发扩展需要Visual Studio Code Insiders

Visual Studio Code Remote Development allows you to use a container, remote machine, or the Windows Subsystem for Linux (WSL) as a full-featured development environment. It effectively splits VS Code in half and runs the client part on your machine and the "VS Code Server" basically anywhere else. The Remote Development extension pack includes three extensions. See the following articles to get started with each of them:

Visual Studio Code远程开发允许您使用容器,远程计算机或Linux的Windows子系统(WSL)作为功能齐全的开发环境。 它有效地将VS Code分成两部分,并在您的计算机和“ VS Code Server”上基本上在其他任何地方运行客户端部分。 远程开发扩展包包括三个扩展。 请参阅以下文章,以开始使用它们:

  • Remote - SSH - Connect to any location by opening folders on a remote machine/VM using SSH. 远程-SSH-通过使用SSH打开远程计算机/ VM上的文件夹来连接到任何位置。
  • Remote - Containers - Work with a sandboxed toolchain or container-based application inside (or mounted into) a container. 远程-容器-在容器内部(或安装到容器中)使用沙盒工具链或基于容器的应用程序。
  • Remote - WSL - Get a Linux-powered development experience in the Windows Subsystem for Linux. 远程-WSL-在Windows子系统中获得Linux驱动Linux开发经验。

Lemme give a concrete example. Let's say I want to do some work in any of these languages, except I don't have ANY of these languages/SDKS/tools on my machine.

雷姆给出一个具体的例子。 假设我想用这些语言中的任何一种来做一些工作,除了我的机器上没有这些语言/ SDKS /工具中的任何一种。

Aside: You might, at this point, have already decided that I'm overreacting and this post is nonsense. Here's the thing though when it comes to remote development. Hang in there.

旁白:在这一点上,您可能已经决定我React过度了,这篇文章是胡说八道。 但是,这涉及到远程开发。 等一下

On the Windows side, lots of folks creating Windows VMs in someone's cloud and then they RDP (Remote Desktop) into that machine and push pixels around, letting the VM do all the work while you remote the screen. On the Linux side, lots of folks create Linux VMs or containers and then SSH into them with their favorite terminal, run vim and tmux or whatever, and then they push text around, letting the VM do all the work while you remote the screen. In both these scenarios you're not really client/server, you're terminal/server or thin client/server. VS Code is a thick client with clean, clear interfaces to language services that have location transparency.

在Windows方面,许多人在某人的云中创建Windows VM,然后他们将RDP(远程桌面)放入该计算机并向周围推像素,从而使VM在远程屏幕上可以完成所有工作。 在Linux方面,很多人创建Linux VM或容器,然后使用自己喜欢的终端SSH到它们中,运行vim和tmux或其他任何东西,然后推送文本,让VM在远程屏幕上完成所有工作。 在这两种情况下,您并不是真正的客户端/服务器,而是终端/服务器或瘦客户端/服务器。 VS Code是一个胖客户端,具有干净,清晰的语言服务接口,这些服务具有位置透明性。

I type some code, maybe an object instance, then intellisense is invoked with a press of "." - who does that work? Where does that list come from? If you're running code locally AND in the container, then you need to make sure both sides are in sync, same SDKs, etc. It's challenging.

我输入一些代码,也许是一个对象实例,然后按“。”键来调用智能感知。 -那是谁工作的? 该清单从何而来? 如果要在容器中本地运行代码,则需要确保双方同步,使用相同的SDK等。这是一个挑战。

OK, I don't have the Rust language or toolkit on my machine.

好的,我的机器上没有Rust语言或工具包。

I'll clone this repository:

我将克隆此存储库:

git clone https://github.com/Microsoft/vscode-remote-try-rust

Then I'll run Code, the Insiders version:

然后,我将运行Insiders版本的Code:

C:\github> git clone https://github.com/Microsoft/vscode-remote-try-rust   
Cloning into 'vscode-remote-try-rust'... 
Unpacking objects: 100% (38/38), done.         
C:\github> cd .\vscode-remote-try-rust\
C:\github\vscode-remote-try-rust [main =]> code-insiders .

Then VS Code says, hey, this is a Dev Container, want me to open it?

然后VS Code说,嘿,这是一个Dev容器,要我打开它吗?

There's a devcontainer.json file that has a list of extensions that the project needs. And it will install those VS Extensions inside a Development Docker Container and then access them remotely. This isn't a list of extensions that your LOCAL system needs - you don't want to sully your system with 100 extensions. You want to have just those extensions that you need for the project you're working on. Compartmentalization. You could do development and never install anything on your local machine, but you're finding a sweet spot that doesn't involved pushing text or pixels around.

有一个devcontainer.json文件,其中包含项目所需的扩展列表。 并将这些VS扩展安装在开发Docker容器中,然后远程访问它们。 这不是您的LOCAL系统需要的扩展列表-您不想让您的系统带有100个扩展。 您只想拥有正在处理的项目所需的那些扩展。 隔离专区。 您可以进行开发,并且永远不会在本地计算机上安装任何东西,但是您发现了一个最佳的地方,它不会牵扯到文本或像素。

visual studio code 远程python解释器 visual studio code 远程开发_大数据_02

Now look at this screenshot and absorb. It's setting up a dockerfile, sure, with the development tools you want to use and then it runs docker exec and brings in the VS Code Server!

现在看一下这个屏幕截图并吸收。 当然,它会使用您要使用的开发工具来设置dockerfile,然后运行docker exec并引入VS Code Server!

visual studio code 远程python解释器 visual studio code 远程开发_python_03

Check out the Extensions section of VS Code, and check out the lower left corner. That green status bar shows that we're in a client/server situation. The extensions specific to Rust are installed in the Dev Container and we are using them from VS Code.

签出VS Code的扩展部分,并签出左下角。 绿色状态栏表示我们处于客户端/服务器状态。 特定于Rust的扩展已安装在开发容器中,我们正在VS Code中使用它们。

visual studio code 远程python解释器 visual studio code 远程开发_linux_04

When I'm typing and working on my code in this way (by the way it took just minutes to get started) I've got a full experience with Intellisense, Debugging, etc.

当我以这种方式输入和处理代码时(只需花几分钟的时间就可以开始使用),我在Intellisense,调试等方面都有完整的经验。

visual studio code 远程python解释器 visual studio code 远程开发_linux_05

Here I am doing a live debug session of a Rust app with zero setup other than VS Code Insiders, the Remote Extensions, and Docker (which I already had).

在这里,除了VS Code Insiders,Remote Extensions和Docker(我已经拥有)之外,我正在使用零设置进行Rust应用程序的实时调试会话。

visual studio code 远程python解释器 visual studio code 远程开发_大数据_06

As I mentioned, you can run within WSL, Containers, or over SSH. It's early days but it's extraordinarily clean. I'm really looking forward to seeing how far and effortless this style of development can go. There's so much less yak shaving! It effectively removes the whole setup part of your coding experience and you get right to it.

如前所述,您可以在WSL,容器或SSH中运行。 现在还很早,但是非常干净。 我非常期待看到这种开发风格能走多远。 牛刮胡的次数要少得多! 它有效地消除了编码经验中的整个设置部分,您可以正确使用它。

Sponsor: Manage GitHub Pull Requests right from the IDE with the latest JetBrains Rider. An integrated performance profiler on Windows comes to the rescue as well.

赞助商:使用最新的JetBrains Rider从IDE直接管理GitHub Pull Requests。 Windows上的集成性能分析器也可以解决。

翻译自: https://www.hanselman.com/blog/visual-studio-code-remote-development-may-change-everything