Testing .NET class library targeting both Windows-only frameworks, and .NET Core 3.0

I am trying to add support for .NET Core to my class library.
It currently targets:

  • .NET Standard 1.6
  • .NET Standard 2.0
  • .NET Core App 1.1
  • .NET Core App 2.1
  • .NET 4.5
  • .NET 4.6
  • .NET 4.7
  • .NET 4.8
    As specified n the TargetFrameworks as part of the .csproj.
    This is running fine on a windows environment on Travis, but when I try to add support for .NET Core 3.1/3.0/2.2 I get:

error NETSDK1045: The current .NET SDK does not support targeting .NET Core 3.1. Either target .NET Core 2.1 or lower, or use a version of the .NET SDK that supports .NET Core 3.1. [C:\Users\travis\build\getyoti\yoti-dotnet-sdk\src\Yoti.Auth\Yoti.Auth.csproj]
from: https://travis-ci.com/getyoti/yoti-dotnet-sdk/builds/140257434

I tried running conditional builds to have .NET 3.0/3.1 run on linux, and have the windows frameworks run on Windows, but it doesn’t seem possible to only restore the frameworks for the framework I would like to test against - build config:

language: csharp
mono: none
solution: Yoti.Auth.sln

jobs:
  include:
    - &testWindows
      stage: Test on Windows
      os: windows
      before_install: cd src
      install: dotnet restore ../test/Yoti.Auth.Tests/Yoti.Auth.Tests.csproj
    - <<: *testWindows
      script: dotnet test Yoti.Auth.sln -c Release --verbosity normal --framework net48
    - <<: *testWindows
      script: dotnet test Yoti.Auth.sln -c Release --verbosity normal --framework net47
    - <<: *testWindows
      script: dotnet test Yoti.Auth.sln -c Release --verbosity normal --framework net46
    - <<: *testWindows
      script: dotnet test Yoti.Auth.sln -c Release --verbosity normal --framework net45 
      
    - &testLinux
      stage: Test on Linux
      dotnet: 3.1
      before_install: cd src
      install: dotnet restore ../test/Yoti.Auth.Tests/Yoti.Auth.Tests.csproj
    - <<: *testLinux
      script: dotnet test Yoti.Auth.sln -c Release --verbosity normal --framework netstandard2.0
    - <<: *testLinux
      script: dotnet test Yoti.Auth.sln -c Release --verbosity normal --framework netstandard1.6
    - <<: *testLinux
      script: dotnet test Yoti.Auth.sln -c Release --verbosity normal --framework netcoreapp3.1
    - <<: *testLinux
      script: dotnet test Yoti.Auth.sln -c Release --verbosity normal --framework netcoreapp2.1
    - <<: *testLinux
      script: dotnet test Yoti.Auth.sln -c Release --verbosity normal --framework netcoreapp2.0
    - <<: *testLinux
      script: dotnet test Yoti.Auth.sln -c Release --verbosity normal --framework netcoreapp1.1

(from https://travis-ci.com/getyoti/yoti-dotnet-sdk/builds/140273006)

I still get the same targeting error though as it tries to restore the packages for all of the frameworks, rather than just the one I need for each step.

Is is possible to achieve what I’m trying to achieve?
Obviously I know it will be once .NET Core 3.1 is supported in the Windows container, but until then, I can’t see a way around this

Im having the same issue. Have you figured this out?

I’m afraid not, I gave up and went to Azure Pipelines. Much easier

Yea azure is the best. I think I figured it out. I just set mono to latest and it seem to pass the builds now. Thanks for the quick response.

Imprint