Edited on 2018-01-15:
I have added a new article describing the same process but using .NET Core (using a library targeting .NET Standard).
It is fairly easy to find examples of the
.travis.yml file including the
apt-get commands installing mono but it isn’t required anymore.
Travis CI has now an easier way of doing things when it comes to building C# (even if it is stated that this is beta and that it could be removed at anytime…)
Here is what the
.travis.yml file I used ended up looking:
1 2 3 4 5 6 7 8 language: csharp solution: solution-name.sln before_install: - sudo apt-get install nunit-console before_script: - nuget restore solution-name.sln after_script: - nunit-console Tests/bin/Release/Tests.dll
The first and second lines are obvious and documented.
But using NUnit is not and requires the console to be installed (line 4) and run using the test project output (the .dll file, line 8).
Release (which is the default) can be replaced by the build configuration you are using using the following
1 2 3 4 5 6 7 8 9 language: csharp script: - xbuild /p:Configuration=Debug solution-name.sln before_install: - sudo apt-get install nunit-console before_script: - nuget restore solution-name.sln after_script: - nunit-console Tests/bin/Debug/Tests.dll
Line 3 and 9 need to be adapted to your build configuration (
Debug might need to be changed to match your configuration name).
See something wrong or want to ask a question? Get in touch on Twitter