views:

313

answers:

3

I am automating my build process using TeamFoundation and I need to choose what projects to compile according to the .proj file from the build. Here is the full scenario:

I have a .proj file which uses a .sln file in order to compile a solution which contains 2 websites. The .sln file is configured to compile both websites in Release configuration.

My goal is to compile only 1 website per build type, namely I want the BuildType1 to compile website 1 and BuildType2 to compile the website 2.

Is is possible to "modify" the .sln in such a way that I can unmark one of the websites to compile? Since it is an automated process, I can't change the .sln manually every time I want to compile only one website.

Thanks in advance,

Carlos Amigo

+1  A: 

Look at the SolutionToBuild section in the TFSBuild.proj file.

<SolutionToBuild Include="$(BuildProjectFolderPath)/path/MySolution.sln">
   <Targets>MyCustomTarget1;MyCustomTarget2</Targets>
   <Properties> Configuration=Release</Properties>
</SolutionToBuild>
leppie
Thanks for your reply, leppie.Let me see if I got what you said, If I make a custom target to each project I don't want to compile, those targets will overrite the default targets and if I simply let them empty it will skip the compilation of the project?If so, how can I link a target with a project? I mean, Lets say I have 50 projects in my solution, I want to skip the compilation of one of them, can I do it modyfing only the TFSBUILD.proj file, since I can't change the .csproj of each project?
You can create a new config at solution level (the IDE will ask if you want to create the config for the projects too). Note: You will only modify the Configuration part in the .proj, so the rest can be easily tested on the client side.
leppie
Hmm, I got it..I think the required changes in the solution are simple enought to ask the development team do it, I don't think they will complain about it.Thanks leppie!
A: 

I have the same problem. I have got a solution with lots of csproj in it and I need to build some of them only. I'm not quite getting what I need to do! Can you please explain the solution for dummies like me ;) Thanks Nafise

Nafise
+1  A: 

There are two main ways you can control the build:

  • create a separate Build Type in your Team Explorer. This will have its own completely independent TFSBuild.proj file, so it can build the same code-base in a completely different way. Set the SolutionToBuild up to build just what you want (as described in the accepted answer).

  • Use one Build Type, and set its TFSBuild.proj up to use a property to control what is built (this requires more in depth understanding od MSBuild scripts). In the Queue New Build dialog you can then use the /p: command line flag to set the property as you need it. e.g. "/p:IncrementalGet=false;IncrementalBuild=false;ForceGet=true" will force a normally incremental build to do a full rebuild. This is useful for occasoinal situations, but not a good idea for day to day builds as you have to set the parameters by hand every time.

Jason Williams