Visual Studio Code Raspberry Pi



  1. Visual Studio Code Raspberry Pi Zero W
  2. Visual Studio On Raspberry Pi
  3. Visual Studio Code Raspbian
Visual Studio Code Raspberry Pi-->

Deployment of .NET apps to Raspberry Pi is identical to that of any other platform. Your app can run as self-contained or framework-dependent deployment modes. There are advantages to each strategy. For more information, see .NET application publishing overview.

Deploying a framework-dependent app

To deploy your app as a framework-dependent app, complete the following steps:

  1. Ensure SSH is enabled on your Raspberry Pi. If needed, refer to Enable SSH in the Raspberry Pi documentation.

  2. Install .NET on the Raspberry Pi using the dotnet-install scripts. Complete the following steps from a Bash prompt on the Raspberry Pi (local or SSH):

    1. Run the following command to install .NET:

      Note

      This installs the latest version. If you need a specific version, add --version <VERSION> to the end, where <VERSION> is the specific build version.

    2. To simplify path resolution, add a DOTNET_ROOT environment variable and add the .dotnet directory to $PATH with the following commands:

    3. Verify the .NET installation with the following command:

      Verify the displayed version matches the version you installed.

  3. Publish the app on the development computer as follows, depending on development environment.

    • If using Visual Studio, deploy the app to a local folder. Before publishing, select Edit in the publish profile summary and select the Settings tab. Ensure that Deployment mode is set to Framework-dependent and Target runtime is set to Portable.
    • If using the .NET CLI, use the dotnet publish command. No additional arguments are required.
  4. Using an SFTP client, copy the files from the publish location on the development computer to a new folder on the Raspberry Pi.

    For example, to use the scp command to copy files from the development computer to your Raspberry Pi, open a command prompt and execute the following:

    Where:

    • The -r option instructs scp to copy files recursively.
    • /publish-location/ is the folder you published to in the previous step.
    • pi@raspberypi is the user and host names in the format <username>@<hostname>.
    • /home/pi/deployment-location/ is the new folder on the Raspberry Pi.

    Tip

    Recent versions of Windows have OpenSSH, which includes scp, pre-installed.

  5. From a Bash prompt on the Raspberry Pi (local or SSH), run the app. To do this, set the deployment folder as the current directory and execute the following command (where HelloWorld.dll is the entry point of the app):

Deploying a self-contained app

To deploy your app as a self-contained app, complete the following steps:

Studio

Microsoft’s Visual Studio Code is an excellent C development environment, and now it’s an easy install on Raspberry Pi. Here’s Jim Bennett from Microsoft to show you all how to get VS Code up and running on our tiny computer. In a previous video, I had posted instructions on installing Visual Studio Code on the Pi. That is nolonger necessary; you can now grab the ARM binaries stra.

  1. Ensure SSH is enabled on your Raspberry Pi. If needed, refer to Enable SSH in the Raspberry Pi documentation.

  2. Publish the app on the development computer as follows, depending on development environment.

    • If using Visual Studio, deploy the app to a local folder. Before publishing, select Edit in the publish profile summary and select the Settings tab. Ensure that Deployment mode is set to Self-contained and Target runtime is set to linux-arm.

    • If using the .NET CLI, use the dotnet publish command with the -r linux-arm argument:

  3. Using an SFTP client, copy the files from the publish location on the development computer to a new folder on the Raspberry Pi.

    For example, to use the scp command to copy files from the development computer to your Raspberry Pi, open a command prompt and execute the following:

    Where:

    • The -r option instructs scp to copy files recursively.
    • /publish-location/ is the folder you published to in the previous step.
    • pi@raspberypi is the user and host names in the format <username>@<hostname>.
    • /home/pi/deployment-location/ is the new folder on the Raspberry Pi.

    Tip

    Recent versions of Windows have OpenSSH, which includes scp, pre-installed.

  4. From a Bash prompt on the Raspberry Pi (local or SSH), run the app. To do this, set the current directory to the deployment location and complete the following steps:

    1. Give the executable execute permission (where HelloWorld is the executable file name).

    2. Run the executable.

Visual Studio Code Raspberry Pi
Sponsored By

Four years ago I wrote how to BUILD (literally compile) Visual Studio Code for a Raspberry Pi ARM machine. Just a few months later in November, community member Jay Rodgers released his labor of love - nightly builds of VS Code for Chromebooks and Raspberry Pi.

If you want to get unofficial builds of Visual Studio Code running on a Raspberry Pi (I know you have one!) you should use his instructions. He has done a lot of work to make this very simple. Head over to http://code.headmelted.com/ and make it happen for yourself, now!

Jay says:

I've maintained the project for a few years now and it has expanded from providing binaries for Pi to providing support and tools to get VS Code running on low-end ARM devices that might not otherwise support it like Chromebooks (which make up about 60% of the devices in schools now).

The project has really taken off among educators (beyond what I would have thought), not least because they're restricted to the devices provided and it gives them a route to teach coding to students on these computers that might not otherwise be there.

Again, Jay is doing this out of love for the community and the work that makes it happen is hosted at https://github.com/headmelted/codebuilds. I'd encourage you to head over there right now and give him a STAR.

There's so many community members out there doing 'thankless' work. Thank them. Thank them with a thank you email, a donation, or just your kindness when you file an issue and complain about all the free work they do for you.

Visual Studio Code Raspberry Pi Zero W

I just picked up a Raspberry Pi 4 from Amazon, and I was able to get a community build of VS Code running on it easily!

Open a terminal, run 'sudo -s' and then this script (again, the script is open source):

Jay has done the work! That's just the apt instructions, but he's got Chrome OS, APT, YUM, and a manual option over at http://code.headmelted.com/!

Thank you for making this so much easier for us all.

Love Raspberry Pis? Here's some fun stuff you can do with the Raspberry that you bought, the one you meant to do fun stuff with, and the one in your junk drawer. DO IT!

  • You can even install this week's sponsor Couchbaseon a Raspberry Pi!

Enjoy!

Visual Studio On Raspberry Pi

Sponsor: Couchbase gives developers the power of SQL with the flexibility of JSON. Start using it today for free with technologies including Kubernetes, Java, .NET, JavaScript, Go, and Python.

Visual Studio Code Raspbian

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.


AboutNewsletter