user1147862
user1147862

Reputation: 4226

Using NUnit and Nuget with Bamboo Cloud

I'm trying to create a plan on Bamboo Cloud (not Bamboo Server) for a .Net project:

  1. Check out from Bitbucket
  2. Nuget to get all package
  3. MSBuild to compile the solution
  4. NUnit to run the unit tests

1) and 3) is easy, but I can't figure out how to create tasks that run Nuget and NUnit. It seems you first have to install the executables on the build agent. I found documentation on how to do this for Linux, but not for Windows.

How do I create Nuget and NUnit tasks with Bamboo Cloud?

Upvotes: 1

Views: 253

Answers (1)

Marakai
Marakai

Reputation: 1212

I did this by splitting up my Job into 4 tasks:

  1. Source Code Checkout

As you would expect. It's the default task within a job anyway.

  1. Download NuGet.exe

A one-liner Powershell inline script with

Invoke-WebRequest -Uri 'http://nuget.org/nuget.exe' -OutFile '.\nuget.exe'
  1. Download all package dependencies via NuGet

This approach now seems to be the "new" recommended approach, so it's a simple CMD file that executes

nuget.exe restore
  1. MSBuild

Using the .SLN file as parameter for the Project File option in the task and passing any needed other msbuild options in the Options field

My Bamboo server is on Linux and my remote agent is on the Windows build machine.

In your case you would follow up with the 5. task, e.g. the Nunit tests - though you may decided to put that into a separate stage, and split the tests into jobs that can run in parallel.

Edit: almost forgot: I also have a Nuget.config file

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageRestore>
    <!-- Allow NuGet to download missing packages -->
    <add key="enabled" value="True" />
    <!-- Automatically check for missing packages during build in Visual Studio -->
    <add key="automatic" value="True" />
  </packageRestore>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    <add key="nuget.org" value="https://www.nuget.org/api/v2/" />
    <add key="Syncfusion" value="http://nuget.syncfusion.com/xamarin/" />
  </packageSources>
  <!-- Used to specify which one of the sources are active -->
  <activePackageSource>
    <!-- this tells only one given source is active -->
    <add key="NuGet official package source" value="https://nuget.org/api/v2/" />
    <!-- this tells that all of them are active -->
    <add key="All" value="(Aggregate source)" />
  </activePackageSource>
</configuration>

Upvotes: 1

Related Questions