Exclude .csproj from VisualStudio 2012.sln when using Mono Compiler

I want to build my VisualStudio 2012 (.sln) solution using Mono, but it cannot compile projects that rely on VisualStudio-specific assemblies. For instance.

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? 

In this case, HypervResourceControllerTest.cs (18,17) is a link to Visual Studio testing tools:

 using Microsoft.VisualStudio.TestTools.UnitTesting; 

Since I don't need a testing environment to compile, can I tell the Mono compiler to work around a specific project in .sln?

+4
source share
1 answer

Create a new configuration, say xbuild to use it:

  • In Visual Studio, create a new configuration that excludes projects that you are not interested in. - (Build β†’ Configuration Manager ..., select Active solution on the platform: drop-down list)

  • Using Configuration Manager, remove unnecessary solutions from the configuration.

  • Then close VisualStudio, which will save the changes .sln and .csproj..sln will record which projects are related to the configuration..csproj will record the configuration settings, for example, whether TRACE or DEBUG is determined.

  • Finally, when calling xbuild, assign your configuration name in the Configuration property.

eg.

 xbuild /p:Configuration="NoUnitTests" ServerResource.sln 

The above will build projects related to NoUnitTests configuration.

+4
source

Source: https://habr.com/ru/post/1496118/


All Articles