Put almost everything into MSBuild scripts, so that you and other developers can run the same steps locally via the command line. Otherwise, when something goes wrong with the build, you have to debug it on the CC server. Not a nice debugging experience. Also, you want to run the build locally before committing to make sure it works.
The few things that I wouldn'T put into MSBuild scripts are:
- SVN update, as CC has to do this anyway, and you usually don't want to update when doing a local build. (Well, I do type
svn up && msbuild
quite often, but that's so short that I don't need to put this into a script.)
- Creation and publishing of build reports; again this is CC's domain, and not useful locally
As for structuring your MSBuild files, you will want a "master" build script that you can use to build everything or just some targets, e.g.
MSBuild /t:Build
to just build the code incrementally
MSBuild /t:Rebuild
for a clean rebuild
MSBuild /t:UnitTest
to just run unit tests
MSBuild
for the most frequent choice, say, equivalent to t:Build;UnitTest
MSBuild /t:All
to build code, documentation, and setup cleanly, run all tests, and package the results
You can also add "shortcut" targets for popular variations.
Having a single master build file doesn't mean that everything is defined in this single file; you can include other msbuild files, and/or call msbuild recursively to organize your build. For example:
- The master .proj file should be relatively simple; mainly, it should define project-specific stuff like the list of solutions to build, and project-specific overrides
- Let the master file include a single .targets file that contains targets and default properties; strive to keep this project-neutral and reusable.
- If the .targets file becomes too large, split it up into separate files, e.g. one for code, one for help and documentation, one for setup and packaging. Let your main .targets file include those sub-files, so that your .proj file still needs only include one file
- Likewise you can split up the master .proj file if needed, e.g. by subsystem.