I am currently trying to build a Microsoft Runtime Component C# class library targeting Windows Phone 8.1, Windows app 8.1 and Windows 10 Universal app. To complete this introduction, my environment runs Windows 8.1 and I am using Visual Studio 2015 as IDE.
In order to automatize a process, in my team we need to compile that library through the command-line to use the resulting .winmd
file in somewhere else. Although the solution and project compiles perfectly with the IDE, we are not able to compile our project through the windows command line. After some investigation we found a possible command that might work, but we get errors that tell us that we are missing some arguments. The command line is the next one:
C:\solutionDir>"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe" project\project.csproj
After clearing the project, and executing this command we get a bunch of this errors:
"C:\solutionDir\project\project.csproj" (default target) (1) ->
(CoreCompile target) ->
Class1.cs(2,15): error CS0234: The type or namespace name 'System'
does not exist in the namespace 'Windows' (are you missing an assembly
reference?) [C:\solutionDir\project\project.csproj]
Other errors, but all coming from the same missing namespace 'Windows', are the miss of namespace with name ApplicationModel
, Devices
, Security
and Networking
. This namespaces names are part of the Windows RT C# API which looks like it is not present during the execution of this command.
As I said, looks like we are not specifying all the arguments needed to achieve the compilation or perhaps we are not doing it properly. What is the proper way to build a VS C# project class library which targets universal apps with the command line?
I assume that I was using an older version of the MSBuild.exe. In order to make it work, I had to install the standalone version of the MSBuild. The command file can be found in here:
You can specify the configuration (Debug|Release) with the argument:
Or even better: