[英]Build Windows Universal C# class library from command line
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. 我目前正在尝试构建针对Windows Phone 8.1,Windows应用程序8.1和Windows 10通用应用程序的Microsoft运行时组件C#类库。 To complete this introduction, my environment runs Windows 8.1 and I am using Visual Studio 2015 as IDE.
为了完成本介绍,我的环境运行Windows 8.1,并且使用Visual Studio 2015作为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. 为了使过程自动化,在我们的团队中,我们需要通过命令行编译该库,以在其他地方使用生成的
.winmd
文件。 Although the solution and project compiles perfectly with the IDE, we are not able to compile our project through the windows command line. 尽管该解决方案和项目可以使用IDE完美地编译,但是我们无法通过Windows命令行来编译我们的项目。 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
. 其他错误(都是来自相同缺少的名称空间“ Windows”)都是名称为
ApplicationModel
, Devices
, Devices
, Security
和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. 该名称空间名称是Windows RT C#API的一部分,在执行此命令期间看起来好像不存在。
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 ?
用命令行构建针对通用应用程序的VS C#项目类库的正确方法是什么 ?
I assume that I was using an older version of the MSBuild.exe. 我假设我使用的是旧版本的MSBuild.exe。 In order to make it work, I had to install the standalone version of the MSBuild .
为了使其工作,我必须安装MSBuild的独立版本 。 The command file can be found in here:
命令文件可以在这里找到:
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" project\project.csproj
You can specify the configuration (Debug|Release) with the argument: 您可以使用以下参数指定配置(Debug | Release):
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" project\project.csproj /property:Configuration=Release
Or even better: 甚至更好:
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" project\project.csproj /t:rebuild /property:Configuration=Release
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.