Jenkins: Configure CI with TFS, NSUnit – Build, Package

Today I want to tell about the way to create a C.I. with Package and Deploy with Jenkins. Jenkins is “an extendable open source continuous integration server”. There are a lot of good articles on internet which explain what is jenkins and the base configuration

but it is difficult to find tutorial or article that discuss about NSUnit, configuration and Packages together. First of all we need to create a a simple MSBuild script with all steps that we need.
In this first post, we can discus about the msbuild script. Now we prepare a script to put inside our jenkins:

1 – Clean Solution

	<Solution Include="${RootPath}\src\TestProjectComplete.sln"/>
<Target Name="Clean">
	<Message Importance="high" Text="Cleaning folders"/>
	<RemoveDir Directories="$(BinPathUnitTests)" />
	<!-- Clean the source code projects -->
	<MSBuild Projects="@(ProjectFiles)"
	Properties="Configuration=$(Configuration)" />

2 – Get packages from Nuget

<!-- The LoadNuGetPackages Target -->
	<NuGetPackageConfigs Include="E:\workspace\TestProjectComplete\src\**\packages.config" />
<Target Name="LoadNuGetPackages">
	<Message Importance="high" Text="Retrieving packages for %(NuGetPackageConfigs.Identity)" />
	<Exec Command="&quot;$(SrcPath)\.nuget\nuget&quot; install &quot;%(NuGetPackageConfigs.Identity)&quot; -o &quot;$(SrcPath)\packages&quot;" />

3 – Build projects

<Target Name="Compile">
	<Message Importance="high" Text="Compiling projects"/>
	<MakeDir Directories="$(BinPathUnitTests)" />
	<MSBuild Projects="$(SrcPath)\TestProjectComplete\TestProjectComplete.csproj" Properties="Configuration=$(Configuration);Platform=$(Platform)" />

4 – Run unit test

<!-- Running Test -->
<Target Name="NUnit">
		<TestAssembly Include="$(BinPathUnitTests)\*.test.dll" />
	<Message Text="NUnit is running on: @(TestAssembly)" />
	<Nunit ToolPath="$(NUnit-ToolPath)" Assemblies="@(TestAssembly)" OutputXmlFile="$(BinPathUnitTests)\test-results.xml"/>

5 – Packages

<Target Name="Package">
	<MakeDir Directories="$(Publish)" />		
	<MSBuild Projects="$(SrcPath)\TestProjectComplete\TestProjectComplete.csproj"
		Targets="ResolveReferences;_CopyWebApplication" />

In my Github repository you can find the msbuild script (here). The next post we discuss how to configure jenkins to use this script.


Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo di

Stai commentando usando il tuo account Chiudi sessione /  Modifica )

Google photo

Stai commentando usando il tuo account Google. Chiudi sessione /  Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione /  Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione /  Modifica )

Connessione a %s...