Building your solutions using MSBuild – Part 1

Many people seem to be afraid of the angled brackets that accompany MSBuild and tend to avoid it. This is a pity as MSBuild can be as simple or complex as you want to make it. The beauty of the tool is that it’s kinda like Lego; you build it bit by bit, enhance it, break it, build it better.

I thought in Part 1 of this series I’d keep it as simple as possible and show how to compile a solution using MSBuild. We’ll need a starting point, so I’ve attached a sample application that will be used throughout. Note, this sample application uses the Microsoft Solutions Build Framework (v2.0.060717.001) from GotDotNet. You can download this now and take a look, or you can follow this series and see how we take a basic solution compiling to something a little more useful. The SBF provides a bunch of MSBuild tasks, so we don’t need to write them ourselves!

  1. Download and unzip the attached file to your PC
  2. Open a .NET 2.0 command prompt to the path of the Build.Proj file
  3. Run MSBuild.exe Build.proj

You should see a successful build of your solution (assuming it compiles ok).

That’s all there is to it. Add the build folder to each of your solutions, then a few lines of MSBuild configuration and you can compile your solution. In fact the only part you should need to change in to compile your solution is the orange part below

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Full" xmlns="">
<Import Project="support\Microsoft.Sdc.Common.targets"/>
<Target Name="Full">
<Tools.DevEnv VisualStudio="8.0" Path="$(MSBuildProjectDirectory)\..\SampleConsoleApp\SampleConsoleApp.sln" Config="Release" Clean="true"/>

Great! But we need more. What about SourceSafe / TFS integration. What about notifications. What about deployment. What about labeling. What about FXCop integration….

All this is to come, but first get yourself accustomed to the simple sample in part 1.

This entry was posted in MSBuild. Bookmark the permalink.

One Response to Building your solutions using MSBuild – Part 1

  1. Kevin says:

    How do I get the "attached sample application"? This might be silly, but I don\’t see anything to download.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s