MSBuild is the build system for Visual Studio. All Visual Studio solution and project files are MSBuild compatible XML files. You can use MSBuild to build and execute LiquidTest projects by either directly referencing a LiquidTest project file (.csproj file), or you can write a custom MSBuild script yourself. This document is about creating a custom build script, very similar to our NAnt example
The discussion of MSBuild tasks and other elements is beyond the scope of this document, but the full documentation for MSBuild is available on-line
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="test" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SourceDirectory>.\src</SourceDirectory>
<LibDirectory>.\lib</LibDirectory>
<BuildDirectory>.\bin</BuildDirectory>
<OutputAssembly>Tests.dll</OutputAssembly>
<OutputReport>Tests-Results.xml</OutputReport>
</PropertyGroup>
<ItemGroup>
<FilesToDelete Include="$(BuildDirectory)\*.*" />
<FilesToCopy Include="$(LibDirectory)\*.dll" />
<FilesToCopy Include="$(LibDirectory)\*.xml" />
<FilesToCopy Include="$(LibDirectory)\*.properties" />
<LibPaths Include="$(LibDirectory)" />
</ItemGroup>
<Target Name="clean">
<Delete Files="@(FilesToDelete)" />
<RemoveDir Directories="$(BuildDirectory)" />
<MakeDir Directories="$(BuildDirectory)" />
<Copy SourceFiles="@(FilesToCopy)" DestinationFolder="$(BuildDirectory)" />
</Target>
<ItemGroup>
<Sources Include="$(SourceDirectory)\**\*.cs" />
<References Include="System.dll" />
<References Include="NUnit.Core.dll" />
<References Include="NUnit.Framework.dll" />
<References Include="LiquidTest.Net.dll" />
<References Include="LiquidTestNUnitAddin.dll" />
</ItemGroup>
<Target Name="build-tests" DependsOnTargets="clean">
<Csc TargetType="library" OutputAssembly="$(BuildDirectory)\$(OutputAssembly)" Sources="@(Sources)" References="@(References)" AdditionalLibPaths="@(LibPaths)"/>
</Target>
<Target Name="test" DependsOnTargets="build-tests">
<Exec Command="nunit-console-x86.exe $(OutputAssembly) /xml=$(OutputReport)" ContinueOnError="true" WorkingDirectory="$(BuildDirectory)" />
</Target>
</Project>
To invoke an execution of your LiquidTest tests, execute the following command
msbuild liquidtest.msbuild /t:test
where “liquidtest.msbuild” referes to the name of your MSBuild xml file, /t:test invokes the MSBuild target named “test”
If you get an error about msbuild not being recognised as a command, simply execute the Visual Studio vcvars.bat file:
call "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86