使用Mono Compiler时,从VisualStudio 2012 .sln中排除.csproj

Don*_*rty 4 mono xbuild visual-studio-2012

我想用Mono构建我的VisualStudio 2012解决方案(.sln),但它无法编译依赖于VisualStudio特定程序集的项目.例如

xbuild ServerResource.sln
...
HypervResourceControllerTest.cs(18,17): error CS0234: The type or namespace name `VisualStudio' does not exist in the namespace `Microsoft'. Are you missing an assembly reference?
Run Code Online (Sandbox Code Playgroud)

在这种情况下,HypervResourceControllerTest.cs(18,17)是对Visual Studio测试工具的引用:

using Microsoft.VisualStudio.TestTools.UnitTesting;
Run Code Online (Sandbox Code Playgroud)

由于我不需要编译测试环境,我可以告诉Mono编译器绕过.sln中的特定项目吗?

Don*_*rty 5

创建一个新配置,告诉xbuild使用它:

  1. 在Visual Studio中,创建一个排除您不感兴趣的项目的新配置. - (构建 - >配置管理器...,在Active解决方案平台上选择:下拉列表)

  2. 使用配置管理器,从配置中删除不需要的解决方案.

  3. 接下来,关闭VisualStudio,它将保存对.sln和.csproj的更改.sln将记录与配置关联的项目..csproj将记录配置的设置,例如是否定义了TRACE或DEBUG.

  4. 最后,当调用xbuild时,将配置的名称分配给Configuration属性.

例如

xbuild /p:Configuration="NoUnitTests" ServerResource.sln
Run Code Online (Sandbox Code Playgroud)

以上将构建与NoUnitTests配置相关的项目.