4

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?

Donal Lafferty
  • 5,807
  • 7
  • 43
  • 60
  • A simpler approach is to create a separate solution file for Mono, so that you can ignore all Mono-incompatible projects. – Lex Li Aug 12 '13 at 02:20
  • Separate .sln files for IDE and the .sln for build work have to be synchronized manually. Doing so violates the teachings of database design. PS. your website is an excellent source of information. – Donal Lafferty Aug 12 '13 at 08:05

1 Answers1

5

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.

Donal Lafferty
  • 5,807
  • 7
  • 43
  • 60