How to compile and upload to an Arduino using Visual Studio

The standard Visual Studio or Atmel Studio "Build" options will build/compile for Arduino for either a single Arduino project or all Arduino projects in the current current solution.

The standard Visual Studio or Atmel Studio "Debug" options will upload. "Start with or without" debugging will upload for the selected port and board unless you have enabled the Visual Micro debugger in which case use Start>Without debugging. All deploy, publish and start new instance menu and toolbar commands will compile and upload.

On the tools menu you can also override the serial upload and use a programmer instead.

To recap, all of the Visual Studio "build/debug" tool bar buttons, "build" menu items, "debug" menu items,  right click context project menu and keyboard shortcuts provide compile and upload for Arduino.

  • Press the Blue tool bar arrow or SHIFT+F5 for compile and upload (Debug>Start without debugging)
  • Press the Green tool bar arrow or F5 to compile, upload and debug

If you have multiple arduino projects in a single solution you can right mouse menu on a project name to "Set As Startup Project". This governs which project is uploaded when clicking F5 or any of the standard "Start" commands in Visual Studio. The current start up project will be shown in bold in the Visual Studio solution explorer.

All of the above Visual Studio commands will automatically work with Arduino when an Arduino sketch is open. These commands work in the same way for all types of Visuaol Studio applications. The commands are described in more detail in the Microsoft Visual Studio help.

Code Error Tracking

Many code errors will be shown as you type or when you view your source code however some will become more obvious when you try to compile. When you compile you will see a status in the "Sketch Builder" output pane. Errors will also appear in the output pane.

You can drill down to the relevent source code of any errors by double clicking the respective line in the "Sketch Builder" output.