0

We use a msbuild-sonar-scanner image to run some tests on a .net application.

Within the Dockerfile that builds the sonar-scanner image, at some point we perform:

  && echo "deb http://download.mono-project.com/repo/debian stretch main" | tee /etc/apt/sources.list.d/mono-official.list \
    && curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg \
    && mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg \
    && sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-stretch-prod stretch main" > /etc/apt/sources.list.d/dotnetdev.list' \
    && apt-get update \
    && apt-get install -y --no-install-recommends \
    dotnet-sdk-2.1.4 \

However, the tests execution produce the following error

/usr/share/dotnet/sdk/2.1.4/Sdks/Microsoft.NET.Sdk/build/Microsoft.NET.TargetFrameworkInference.targets(135,5): error : The current .NET SDK does not support targeting .NET Core 2.1.  Either target .NET Core 2.0 or lower, or use a version of the .NET SDK that supports .NET Core 2.1. [/builds/enorasys-ss/essapi/src/socstreamsAPI/EssApi.csproj]

How is this possible, given that we use a 2.1.4 version of the dotnet-sdk and since this is the latest version available from the debian repos:

$ sudo apt-cache search dotnet  | grep dotnet-sdk
dotnet-sdk-2.0.0 - Microsoft .NET Core SDK - 2.0.0
dotnet-sdk-2.0.2 - Microsoft .NET Core SDK - 2.0.2
dotnet-sdk-2.0.3 - Microsoft .NET Core SDK - 2.0.3
dotnet-sdk-2.1 - Microsoft .NET Core SDK 2.1.401
dotnet-sdk-2.1.101 - Microsoft .NET Core SDK - 2.1.101
dotnet-sdk-2.1.103 - Microsoft .NET Core SDK - 2.1.103
dotnet-sdk-2.1.104 - Microsoft .NET Core SDK - 2.1.104
dotnet-sdk-2.1.105 - Microsoft .NET Core SDK - 2.1.105
dotnet-sdk-2.1.2 - Microsoft .NET Core SDK - 2.1.2
dotnet-sdk-2.1.200 - Microsoft .NET Core SDK - 2.1.200
dotnet-sdk-2.1.201 - Microsoft .NET Core SDK - 2.1.201
dotnet-sdk-2.1.202 - Microsoft .NET Core SDK - 2.1.202
dotnet-sdk-2.1.3 - Microsoft .NET Core SDK - 2.1.3
dotnet-sdk-2.1.300-preview2-008533 - Microsoft .NET Core SDK 2.1.300 - Preview
dotnet-sdk-2.1.300-rc1-008673 - Microsoft .NET Core SDK 2.1.300 - rc1
dotnet-sdk-2.1.4 - Microsoft .NET Core SDK - 2.1.4
pkaramol
  • 16,451
  • 43
  • 149
  • 324
  • Microsoft changes their Linux installation instructions often, and you seem to use an old version. The latest is https://www.microsoft.com/net/download/linux-package-manager/debian9/sdk-2.1.400 and you need to adapt to that. – Lex Li Aug 23 '18 at 20:13
  • See also https://stackoverflow.com/questions/49171623/the-current-net-sdk-does-not-support-targeting-net-core-2-1-either-target-ne – riQQ Dec 29 '19 at 21:06

1 Answers1

1

TLDR: apt-get install dotnet-sdk-2.1.401, not dotnet-sdk-2.1.4

The version numbers are not like decimal numbers. 2.1.4 is a much lower version than 2.1.300, for example.

You are using .NET Core 2.1.4 SDK, which is actually an old version that only supports .NET Core Runtime 2.0 or earlier. You want to use .NET Core 2.1.300 or later (such as 2.1.301 or 2.1.400 or 2.1.401). Anything past 2.1.300 can target .NET Core Runtime 2.1 too.

.NET Core SDK and Runtime versions dont exactly match up in an "obvious" way. Here's the versions as I understand them:

  • .NET Core SDK 2.0 can target .NET Core Runtime 2.0 or earlier
  • .NET Core SDK 2.1.0 until 2.1.200 also only target .NET Core Runtime 2.0 or earlier
  • .NET Core SDK 2.1.300 and onwards (including 2.1.301, 2.1.400 and 2.1.401) can target .NET Core 2.1 as well as older versions.

You can also see this on https://www.microsoft.com/net/download/dotnet-core/2.1 which will show you all the SDK downloads that can target .NET Core runtime 2.1. The earliest version is 2.1.300 and the latest is 2.1.401. On the other hand, you can see the SDKs that can only target runtime 2.0 here: https://www.microsoft.com/net/download/dotnet-core/2.0. You can see that SDK 2.1.4 targets Runtime 2.0 only.

omajid
  • 14,165
  • 4
  • 47
  • 64