2

MY company is currently building very large solutions that we use as master solutions. Developers can add their projects to the master solution to get them into the nightly builds. However, sometimes projects reference projects that are not in the solutions, which causes some weird issues.

I would like to fail the solution build if any external projects are detected. Is there an MSBuild property that can be set to do this?

Matt Slagle
  • 1,075
  • 9
  • 19
  • by weird issues; do you mean that the build fails? I struggle to see how the build could be a success if referenced projects are not included – Dave Lawrence Dec 10 '13 at 15:43
  • The referenced project is still built, but using the default configuration/platform which is usually Debug/AnyCPU. We build in Release, which means that this project is built in Debug which may not have the correct settings. This is the weirdness without failing. – Matt Slagle Dec 10 '13 at 15:46

1 Answers1

0

See this answer for getting a list of project references for each project in a .sln.

Using that code, you can figure out if any "external" projects exist based on the references and what's in the .sln.

The code itself can go in a custom MSBuild task that will fail on detection of any external projects.

To use the task you'll need to run it somehow from a .csproj/.proj. One simple way would be to a new project that gets built first and overrides the Build target to run the new task.

Another way would be to create a wrapper .proj that first executes MSBuild (with a dummy target) on the .sln to generate the .metaproj, then executes the custom task, and then runs an actual task to build the .sln.

Community
  • 1
  • 1
makhdumi
  • 1,308
  • 11
  • 35
  • I already created the task. I couldn't find any other way. Ill mark this as the answer since I couldn't find an automatic way to do this. – Matt Slagle Dec 18 '13 at 17:30