Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build a solution folder with MSBuild

We have a solution file that contains some solution folders: libraries, unit-tests, applications, etc.

With Visual Studio 2010 we can build only the projects of a given folder by right-clicking on it and using "build" or "rebuild".

This is perfect on the developers' workstations, and we'd like to do the same on the continuous-integration server which uses MSBuild.

So, can we build a solution folder with MSBuild?

Or will we have to create a dedicated solution for each folder?

The conclusion of the below responses is that there isn't any built-in way to do that, but some workarounds:

  • create a dedicated solution with only the selected projects,
  • use a dedicated csproj that will build the selected projects,
  • add a new project which will reference the selected projects in the existing solution file.

I've chosen to use a dedicated solution file as it is the less intrusive and tricky way, though not the more flexible (the dedicated .csproj solution should offer full control).

like image 917
Pragmateek Avatar asked Jun 06 '11 11:06

Pragmateek


2 Answers

Yes, you can build Solutions folders using MSBuild.

msbuild "framework.sln" /t:First\Project:Build

will build the project in the folder called First. However, disk folders and solutions folders must match (I tried it for my solution where they don’t first).

So all you'd have to do is choose a project that has all the other projects in that folder as dependencies.

Also see: MSBuild command-line reference

like image 134
James Woolfenden Avatar answered Sep 28 '22 23:09

James Woolfenden


The short answer is:

Yes, if you want to build specific set of projects (grouped together in a VS solution) with plain MSBuild you will have to create a dedicated MSBuild .proj for each specific set of projects you want to build.

You will not have to create (and maintain) Visual Studio solutions to support your build, but in the end it's the same (an MSBuild .proj vs. a Visual Studio solution).

I have a similar scenario with a set of 60+ .NET projects (.btprpj BizTalk). For developing in Visual Studio, these projects are currently organized in 12 Visual Studio solutions.

For automated build and deploy I created a set of 50+ MSBuild .proj scripts to target every single component (or set of components) I need.

MSBuild offers a lot of possibilities for automating all the stuff around the actual build of the Visual Studio projects (export from version control systems, etc.).

like image 45
Filburt Avatar answered Sep 28 '22 22:09

Filburt