duck9
duck9

Reputation: 406

Can MSBuild ignore a project reference? (BuildProjectReferences doesn't work)

I am trying to make a build script for a .NET solution which consists of several c# projects and one custom project. The custom project can be build by devenv but msbuild chokes on it.

I would like MSBuild to ignore the custom project because I'm already building it with an Exec task. I actually need MSBuild to not even open the custom .proj file because it's in JSON format and thus causes MSBuild to crash out.

The /BuildProjectReferences=false switch doesn't work. MSBuild still tries to read the custom project file. Is there any way around this?

Upvotes: 1

Views: 2336

Answers (3)

duck9
duck9

Reputation: 406

This question stemmed from a project which had a SilverFrost Fortran project alongside several c# class libraries. The solution would only compile using devenv. Msbuild would throw an error on the Fortran project because it doesn't use the standard .csproj format.

Even with /BuildProjectReferences=false, msbuild would try to read the Fortran project and throw an error. The workaround I discovered was to wrap the msbuild task in an nant task which does the following:

  1. Invokes the Fortran command line compiler
  2. Removes all references to the Fortran project from other .csproj projects using the xmlpoke task
  3. Replaces said references with a direct dll reference to the Fortran compiler output
  4. Invokes Msbuild on the modified solution

Upvotes: 2

Arun
Arun

Reputation: 2533

In your project that uses the custom project, can you right click on the Project Dependencies and remove the custom project from the list? You can refer to the custom project's binary output instead.

Upvotes: 0

TonySalimi
TonySalimi

Reputation: 8447

Instead of building your solution once by MSBuild, try to build each project one by one. In this case, you can ignore the desired project. You can also define your own "Exec"-based build in this new script.

Upvotes: 0

Related Questions