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 --> <PropertyGroup> <SolutionFileName>mvc2.sln</SolutionFileName> <NUnit-ToolPath>tools\nunit</NUnit-ToolPath> </PropertyGroup> <ItemGroup> <AllProjects Include="**\*.csproj" /> </ItemGroup> <Target Name="Clean"> <MSBuild Projects="@(AllProjects)" Targets="Clean" /> </Target> <Target Name="Compile"> <MSBuild Projects="@(AllProjects)" Targets="Build" Properties="WarningLevel=1" /> </Target> <Target Name="Test" DependsOnTargets="Clean;Compile"> <NUnit ToolPath="$(NUnit-ToolPath)" DisableShadowCopy="true" Assemblies="test\bin\Debug\test.dll" OutputXmlFile="test-results.xml" /> </Target> <Target Name="Build" DependsOnTargets="Clean;Compile;Test;" /> </Project>
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)
Enjoy!