Quite often when starting a new project you need a build file. Here’s one I like to use to get things going.

 <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
  <!-- Application Configurations -->
    <AllProjects Include="**\*.csproj" />
  <Target Name="Clean">
    <MSBuild Projects="@(AllProjects)" Targets="Clean" />

  <Target Name="Compile">
    <MSBuild Projects="@(AllProjects)" Targets="Build" Properties="WarningLevel=1" />
  <Target Name="Test" DependsOnTargets="Clean;Compile">
	    <NUnit ToolPath="$(NUnit-ToolPath)" DisableShadowCopy="true" Assemblies="test\bin\Debug\test.dll" OutputXmlFile="test-results.xml" />
  <Target Name="Build" DependsOnTargets="Clean;Compile;Test;" />


Note: To run this build you will need to download and install msbuild community tasks.

This build works against a very basic directory structure:

  • src – basic dll for source code
  • test – basic dll for test code

And all it does is:

  • compile
  • clean, and
  • runs tests (via nunit)