Pergunta

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

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 reference to Visual Studio test tools:

using Microsoft.VisualStudio.TestTools.UnitTesting;

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

Foi útil?

Solução

Create a new configuration, tell xbuild to use it:

  1. In Visual Studio, create a new configuration that excludes the projects you're not interested in. -(Build -> Configuration Manager..., select on the Active solution platform: drop down list)

  2. Using the Configuration Manager, remove unwanted solutions from the configuration.

  3. Next, close VisualStudio, which will save changes to the .sln and .csproj The .sln will record which projects are associated with the configuration. The .csproj will record the settings of the configuration, such as whether TRACE or DEBUG is defined.

  4. Finally, when calling xbuild assign your configuration's name to the Configuration property.

E.g.

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

The above will build the projects associated with the NoUnitTests configuration.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top