3 years ago, I wrote a short post about setting up Travis CI with .Net 4.5 (including running the tests with NUnit) and now is time for an update.

I have upgraded the library in the example (MTAServiceStatus on Github) and it is now targeting .NET Standard. The test framework this time around is xUnit (MSTest is still not supported with Travis).

The Travis CI configuration file is now pretty straigthforward and looks like this:

1
2
3
4
5
6
7
8
9
10
language: csharp
mono: none
dotnet: 2.0.0

install:
- dotnet restore

script:
 - dotnet build
 - dotnet test MTAServiceStatus.Tests/MTAServiceStatus.Tests.csproj

The only part that might requires an explanation is mono: none. By default Travis uses the latest mono release but we do not need it anymore with .NET Core. Setting mono: none tells Travis CI to disable it and on the next line we can set the version of the .NET Core SDK that we want to use: dotnet: 2.0.0. All the information about this requirement is here: https://docs.travis-ci.com/user/languages/csharp/#.NET-Core.

Since setting up Travis CI was easier than last time, I took the opportunity to setup AppVeyor to package the library and upload it to NuGet. It will also create a release in GitHub with a zip archive of all the build files and a copy of the NuGet package. This is a little bit more involved than setting up only the Travis CI process but you can find all the information below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
version: 1.0.{build}
skip_tags: true
image: Visual Studio 2017
configuration: Release
dotnet_csproj:
  patch: true
  file: '**\*.csproj'
  version: '{version}'
  package_version: '{version}'
  assembly_version: '{version}'
  file_version: '{version}'
  informational_version: '{version}'
before_build:
- cmd: nuget restore
build:
  publish_nuget: true
  verbosity: minimal
deploy:
- provider: NuGet
  api_key:
    secure: buTns+OxOaxT6NLivjBNcBXweOlxv9y512TP605PAE0OQRhUzjv4B99Suga/R5Eq
  on:
    branch: master
- provider: GitHub
  tag: v$(appveyor_build_version)
  release: v$(appveyor_build_version)
  auth_token:
    secure: ocqFamtfZzSNeNzuwUODEg8Xvjtgsui2P1ban6Gm4UMBpisfJkqVYScfYb7UPRCC
  artifact: /.*\.nupkg/
  on:
    branch: master

I’m using the version number from AppVeyor which is increased every time a build is triggered. You’ll find all the information about the settings here: https://www.appveyor.com/docs/.

I also had to switch from setting the parameters up in the web interface to using a yaml configuration file to get everything working.