Travis CI + Windows Azure App

For one of my open source projects(debesalgo.com) I ended up setting travis CI to build a windows azure application (asp.net) and I wanted to record my findings since some of the problems are not very descriptive.

Build

To start you go to travis-ci.com and make and account then you have to basically mark your project active and submit a .travis.yml file to get it running.

I suggest you start with this:
language: csharp
solution: debesalgo.sln
mono:
– latest

Once you save that into your file your build will attempt to run and you will see and error about tools not matching and the version not being supported this happens if you are using VS2015 and anything above framework 4.5 So let’s downgrade our application to 4.5(Note further released of xbuild will solve this).

Now the next error will mention System.Web.Entity for some reason this file does not download from Nuget so add it to you bin and make sure you force commit it into git.

Once that step is done they build will kick once more and you will be at the point that it says there is an error with your pdb go into your project settings and compile your release version without pdb’s (Note you can use EmitOptions to do a portable pdb also) that will clear this error and get the build phase of this project done. It should look green and building.

Unit Test

Go into your test project remove the reference to the Visual studio quality tools since those are not supported in mono. Add the nuget reference nunit (I’m using 3.0.1) and to the Nunit.VisualStudio.TestAdapter package. Once that is done go and make a test case that we know will always pass. I tend to do this:

[TestFixture]
public class SampleTest
{
[Test]
public void Empty()
{
//Sample test for those joining the project.
Assert.Pass();
}
}

Once we got this we are ready to go modify our travis file to run our unit test we will do this by scripting so it downloads the runner console and additionally makes a call to the compile dll.

My final code for the .travis.yml looks like this:

language: csharp
solution: debesalgo.sln
mono:
– latest
install:
– nuget restore debesalgo.sln
– nuget install NUnit.Runners -Version 3.0.1 -OutputDirectory testrunner
script:
– xbuild /p:Configuration=Release debesalgo.sln
– mono ./testrunner/NUnit.Console.3.0.1/tools/nunit3-console.exe ./debesalgo.Tests/bin/Release/debesalgo.Tests.dll

This configuration assumes a new asp.net azure project but it works and it will compile. If you want to add test code coverage SharpCover is a great tool to use on this stack the big difference is that you will need to use a debug build.

Thanks for reading and remember to add your build badge to your page.

Leave a Reply