通过SSH到Raspberry Pi的Visual Studio Code远程开发很麻烦

There's been a lot of folks, myself included, who have tried to install VS Code on the Raspberry Pi. In fact, there's a lovely process for this now. However, we have to ask ourselves is a Raspberry Pi really powerful enough to be running a full development environment and the app being debugged? Perhaps, but maybe this is a job for remote debugging. That means installing Visual Studio Code locally on my Windows or Mac machine, then having Visual Studio code install its headless server component (for ARM7) on the Pi.

有很多人,包括我自己在内,都试图在Raspberry Pi上安装VS Code 。 实际上,现在有一个可爱的过程。 但是,我们必须问自己, Raspberry Pi是否真的强大到足以运行完整的开发环境以及正在调试的应用程序? 也许,但是也许这是远程调试的工作。 这意味着在我的Windows或Mac计算机上本地安装Visual Studio Code,然后让Visual Studio Code在Pi上安装其无头服务器组件(对于ARM7)。

In January I blogged about Remote Debugging with VS Code on a Raspberry Pi using .NET Core on ARM. It was, and is, a little hacked together with SSH and wishes. Let's set up a proper VS Code Remote environment so I can be productive on a Pi while still enjoying my main laptop's abilities.

在1月,我写了一篇关于在ARM上使用.NET Core在Raspberry Pi上使用VS代码进行远程调试的博客。 它过去和现在都与SSH和愿望一起被黑了。 让我们设置一个合适的VS Code Remote环境,这样我就可以在Pi上高效工作,同时仍然可以享受笔记本电脑的主要功能。

  • First, can you ssh into your Raspberry Pi without a password prompt?

    首先,您可以在没有密码提示的情况下进入Raspberry Pi吗?

    • If not, be sure to set that up with OpenSSH, which is now installed on Windows 10 by default.

      如果没有,请确保使用OpenSSH进行设置,默认情况下,OpenSSH现在已安装在Windows 10上。
    • You know you've got it down when you can "ssh pi@mypi" and it just drops you into a remote prompt.

      您知道可以通过“ ssh pi @ mypi”进行操作时,它就会崩溃,它只是将您放入远程提示符。
  • Next, get Visual Studio Code Insiders plus

    接下来,获取Visual Studio Code Insiders以及

    Next, get Visual Studio Code Insiders plus

    接下来,获取Visual Studio Code Insiders以及

From within VS Code Insiders, hit Ctrl/CMD+P and type "Remote-SSH" for some of the choices.

在VS Code Insiders中,按Ctrl / CMD + P并输入“ Remote-SSH”进行某些选择。

Remote-SSH options in VS Code

I can connect to Host and VS Code will SSH into the PI and install the VS Code server components in ~./vscode-server-insiders and then connect to them. It will take a minute as its downloading a 25 meg GZip and unzipping it into this temp folder. You'll know you're connected when you see this green badge as seen below that says "SSH: hostname."

我可以连接到主机,并且VS Code将通过SSH进入PI,并在〜。/ vscode-server-insiders中安装VS Code服务器组件,然后连接到它们。 下载25兆的GZip并将其解压缩到此临时文件夹将需要一分钟。 当您看到如下所示的绿色徽标“ SSH:主机名”时,就会知道您已连接。

Green badge in VS Code - SSH: crowpi

Then when you go "File | Open Folder" from the main menu, you'll get the remote system's files! You are working and editing locally on remote files.

然后,当您从主菜单转到“文件|打开文件夹”时,您将获得远程系统的文件! 您正在本地处理和编辑远程文件。

My Raspberry Pi's desktop, remotely

Note here that some of the extensions are NOT installed locally! The Python language services (using Jedi) are running remotely on the Raspberry Pi, so when I get intellisense, I'm getting it remoted from the actual machine I'm developing on, not a guess from my local box.

注意这里有些扩展不是本地安装的! Python语言服务(使用Jedi)在Raspberry Pi上远程运行,因此,当我获得智能感知时,我就将其从正在开发的实际计算机上进行了远程处理,而不是在本地机器上进行猜测。

Some extentions are local and others are remote

When I open a Terminal with Ctrl+~, see that I'm automatically getting a remote terminal and I've even running htop in it!

当我使用Ctrl +〜打开终端时,看到我正在自动获取一个远程终端,甚至在其中运行htop!

Check this out, I'm doing a remote interactive debugging session against CrowPi samples running on the Raspberry Pi (in Python 2) remotely from VS Code on my Windows 10 machine! I did need to make one change to the remote settings as it was defaulting to Python3 and I wanted to use Python2 for these samples.

看看这个,我正在对Windows 10计算机上的VS Code远程运行在Raspberry Pi(在Python 2中)上运行的CrowPi示例进行远程交互式调试会话! 我确实需要对远程设置进行一次更改,因为它默认为Python3,并且我想对这些示例使用Python2。

Remote Debugging a Raspberry Pi

This has been a very smooth process and I remain super impressed with the VS Remote Development experience. I'll be looking at containers, and remote WSL debugging soon as well. Next step is to try C#, remotely, which will mean making sure the C# OmniSharp Extension works on ARM and remotely.

这是一个非常顺利的过程,我对VS远程开发的经验印象深刻。 我将研究容器,以及远程WSL调试。 下一步是尝试C#,远程,这将意味着确保了C#OmniSharp扩建工程ARM远程。

翻译自: https://www.hanselman.com/blog/visual-studio-code-remote-development-over-ssh-to-a-raspberry-pi-is-butter

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值