Article 2ZA70 Using .NET Core 2.0 SDK on Travis

Using .NET Core 2.0 SDK on Travis

by
jonskeet
from Jon Skeet's coding blog on (#2ZA70)
Story Image

This is just a brief post that I'm hoping may help some people migrate to use .NET Core 2.0 SDK on Travis. TL;DR: see the end of the post for a sample configuration.

Yesterday (August 15th), .NET Core 2.0 was fully released. Wonderfully, Travis already supports it. You just need dotnet: 2.0.0 in your YAML file.

I decided to experiment with upgrading the Noda Time build to require .NET Core 2.0 SDK. To be clear, I'm not doing anything in the code that requires 2.0, but it simplifies my build scripts:

Additionally, supporting netcoreapp2.0 means I'll be able to run my benchmarks against that as well, which is going to be very interesting. However, my tests still target netcoreapp1.0, and that's where I ran into problems.

Having done the bare minimum to try using 2.0 (edit global.json and .travis.yml) I ran into this error:

The specified framework 'Microsoft.NETCore.App', version '1.0.5' was not found. - Check application dependencies and target a framework version installed at: / - Alternatively, install the framework version '1.0.5'.

That makes sense. Although netcoreapp2.0 is compatible with netstandard1.0 (i.e. you can use libraries targeted to netstandard1.0 in a 2.0 environment) an application targeting netcoreapp1.0 really needs a 1.0 runtime.

So, we need to install just the runtime as well. I'd expected this to be potentially painful, but it's really not. You just need an addons section in the YAML file:

addons: apt: sources: - sourceline: 'deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-trusty-prod trusty main' key_url: 'https://packages.microsoft.com/keys/microsoft.asc' packages: - dotnet-sharedframework-microsoft.netcore.app-1.0.5

Note that in my case, I want netcoreapp1.0 - if you need netcoreapp1.1, you'd probably install dotnet-sharedframework-microsoft.netcore.app-1.1.2.

So, aside from comments etc, my new Travis configuration will look like this:

language: csharpmono: nonedotnet: 2.0.0dist: trustyaddons: apt: sources: - sourceline: 'deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-trusty-prod trusty main' key_url: 'https://packages.microsoft.com/keys/microsoft.asc' packages: - dotnet-hostfxr-1.0.1 - dotnet-sharedframework-microsoft.netcore.app-1.0.5script: - build/travis.sh

I can now build with the 2.0 SDK, and run tests under both netcoreapp1.0 and netcoreapp2.0.

I'm hoping it's just as simple on AppVeyor when that supports 2.0 as well"

External Content
Source RSS or Atom Feed
Feed Location http://codeblog.jonskeet.uk/feed/
Feed Title Jon Skeet's coding blog
Feed Link https://codeblog.jonskeet.uk/
Reply 0 comments