Cross-Compiling Windows IoT Wiring and Arduino Code

download pre-release

Normally Visual Micro will manage any project that conains an Arduino .ino source with a name that matches the current project and containing project folder.

As of 14th April 2017 (build 1704.14) Visual Micro will not be active and attempt to manage Windows IoT projects or any project with an active configuration that defines the following pre-processor constants.




The first two constants are used and automatically defined by windows IoT projects causing Visual Micro not to manage the intellisense or build process.

How to configure code for arduino or for windows ioT

When working in an Arduino project Visual Micro provides an intellisense constant _VMICRO_INTELLISENSE that can be used alongside Visual Studios _MSC_VER to include or exclude code from intellisense and or IoT builds. For example to exclude the Windows IoT StartupTask.cpp from a Visual Micro or build surround the source code with #if defined(_MSC_VER) && !defined(VMICRO_INTELLISENSE)

for example: StartupTask.cpp

#if defined(_MSC_VER) && !defined(_VMICRO_INTELLISENSE)

using namespace Windows::ApplicationModel::Background;

// These functions should be defined in the sketch file

void setup();

void loop();



The test to ensure _MSC_VER is defined wil prevent both the visual micro compiler and the compiler from using the code. The windows IoT core compiler also uses 

The test to ensure _VMICRO_INTELLISENSE is not defined, will ensure that when editing code in the Visual Studio Ide the Visual Micro intellisense will ignore the code.

When atively managing a project, Visual Micro automatically adds a vsarduino.h to the project. This is for intellisense purposes only. In recent updates the vsarduino code is wrapped in a condition that checks for _VMICRO_INTELLISENSE. This will ensure that the windows IoT compiler and all other external (non-visual micro) users of the code will ignore the vsarduino.h (preventing build errors).

How to configure Visual Micro to build the code in a windows IoT project

To activate visual micro for a specific project configuration we simple need to create a new Visual Studio Solution "Configuration" based on an empty configuration. The "Configurations" combox on the tool bar contains an entry called <new>. Use that entry to create a Configuration. For example create a configuration called "Visual Micro". As stated, it is important to create a configuration based on "empty" and NOT inherited from an existing windows IoT configuration such as "Release" or "Debug"

If the Visual Micro "Automatic Debugging" feature is enabled it is also possible to create a configuration with a name that contains the text "Debug" (not case sensitive).

As an example we can create two configurations:-

Visual Micro

Visual Micro Debug

When a Visual Micro configuration is selected Visual Micro will manage the project and update the intellisense, otherwise the project will work as a normal windows IoT project.

Installing Microsoft Windows 10 IoT

There are currently two different extensions, one for Visual Studio 2015 and one for Visual Studio 2017. Searching for "IoT" in "Visual Studio > Tools > Extensions and Updates > Online" is the easiest way to install. Close the IDE once the installer starts.