Alex Rivera | Logout

MSBuild -- Use the .csproj file or roll your own?

Asked 2008-10-20T21:49:37.663
21

OK, so I readily concede that I'm a newbie when it comes to continuous integration.

That being said, I'm trying to set up a CC.NET environment to educate myself, but I'm having trouble finding the information I need to get the automated build portion set up.

As I understand it, in C# the .csproj file produced by VS 2005 and forward is a valid MSBuild file. To wit, I've been able to integrate the MSBuild task into CC.NET using the .csproj file, but I have a few issues with this:

  1. There's a lot going on in here that I'm not sure I really need in an automated build environment.
  2. I didn't create this file. I do not understand it, and that scares me. (Programming By Coincidence)
  3. Most of what is going on seems to be abstracted through $(MSBuildToolsPath)\Microsoft.CSharp.targets
  4. As a result of 1, 2, and 3, modifying the file to include something like MbUnit seems convoluted and more difficult than it needs to be. My only real option is to include it in the AfterBuild section, which seems kind of like a hack to me.

So, a few questions for the CC.NET folks, the MSBuild folks, and the MbUnit folks.

  1. When using MSBuild, is it advisable to use the VS-generated .csproj file as the build file? Or should I create my own?
  2. Should MbUnit tests be part of the MSBuild file or the CC.NET file? My research seems to suggest that they belong in the MSBuild file. If that is the case, do I create a new MSBuild .proj file and check that in to CVS in addition to the .csproj file? Or does the MbUnit task become part of my .csproj file?
  3. Similar to question 2. If I add the MbUnit tests to the MSBuild file and end up using the .csproj file, is the Target Name="AfterBuild" really the section to add that information? Shouldn't there be a
    Edit
    Report

1 Answer

4

Leave the csproj file well alone (as you say, you don't understand it).

Create your own msbuild proj file and call the csproj (or sln) from your main build file via the msbuild task. Tell your CI server to build your build file.

This seperation makes it easier to add your own pre and post tasks (unit tests, smoke testing SQL scripts, fxcop/other static analysis, etc.) and you won't break your working environment. It also means you can do your custom targets in whatever you wish (msbuild/ant, etc.) Have a look as MSBuildContrib on codeplex for extra goodness.

You don't need visual stuido on your build server (unles you have deployment projects, unless this has also been changed since I last looked)

answered 2008-10-20T23:05:44.127

Your Answer