instalacion-visual-studio-nanoframework

How to Install Visual Studio and nanoFramework

  • 4 min

The development environment is the set of tools for compiling and debugging C# on a microcontroller.

In the Arduino world, we are used to its IDE: simple, functional, but limited.

When moving to nanoFramework, we take a qualitative leap. We are going to use Visual Studio 2022, Microsoft’s flagship integrated development environment (IDE).

This means we will have intelligent autocomplete (IntelliSense), code refactoring, NuGet package management, and, most importantly, a professional debugger.

In this post, we are going to prepare all the necessary software ecosystem to start working.

Although it is possible to use VS Code, the most complete and recommended experience by the nanoFramework team is to use Visual Studio (Community, Professional, or Enterprise edition).

Install Visual Studio

If you are already a .NET developer, you probably have it already. If not, you need to install it. The Community version is free for students, Open Source projects, and individual use, and it is fully functional.

Download the installer from the official Microsoft website.

Run the installer.

The Workload

Visual Studio is modular, so we don’t need to install everything (it would weight gigabytes and gigabytes).

On the workload selection screen, make sure to check:

  • .NET desktop development

You don’t strictly need the “Web development” or “Azure” workloads for nanoFramework, but the desktop one includes the base C# tools and the CLR that we need.

Install the nanoFramework Extension

Once Visual Studio is installed, we need to teach it how to talk to our microcontrollers. This is done through an official extension.

Open Visual Studio.

In the top menu, go to Extensions > Manage Extensions.

In the search box (top right), type nanoFramework.

Download the one called ”.NET nanoFramework Extension”.

Once downloaded, you will need to close Visual Studio for the VSIX installer to run. Click “Modify” and wait for it to finish.

This extension adds two fundamental things:

  1. Project templates (to create a new “nanoFramework Blank App”).
  2. The Device Explorer: A window to see which devices are connected via USB.

Install the CLI Tool nanoff

Although the Visual Studio extension can do many things, there is a command-line tool called nanoff that is essential for firmware management (flashing the device).

It is much more robust than doing it from the graphical interface and will allow us to easily update our ESP32 or STM32 boards to the latest nanoCLR version.

Since we have already installed the .NET environment, we have access to the dotnet command. Open a terminal (PowerShell or CMD) and type:

dotnet tool install -g nanoff
Copied!

If everything went well, typing nanoff --version should show the installed version.

If you get an error saying the command is not recognized, make sure to close and reopen the terminal after the installation.

Install USB Serial Port Drivers

For Visual Studio (and your computer) to see the board, you need the drivers for the USB-Serial converter chip on your board.

This is identical to when you use Arduino. Depending on your board (especially if it’s a cheap ESP32), it will have one of these two chips:

  • CP210x: Common on Espressif development boards and NodeMCU v2.
  • CH340/CH341: Very common on Chinese clones and Lolin/Wemos boards.

If you connect the board and in Windows Device Manager it appears as “Unknown device”, you need to install these drivers.

Verify the Installation with Device Explorer

Let’s check that everything is in order.

Open Visual Studio 2022.

Go to the menu View > Other Windows > Device Explorer.

A panel will open (usually at the bottom or on the right). This panel is your command center. This is where your ESP32 will appear when you connect it.

If you connect your board now, it is likely that it still won’t appear or it won’t recognize it correctly. That’s okay.

This is normal because your board doesn’t have the nanoFramework firmware installed yet. It comes from the factory with the AT firmware or with whatever you last programmed in Arduino.

With Visual Studio, the extension, and nanoff installed, we have the software ready. In the next article, we will erase the previous firmware from the microcontroller and install nanoFramework.