dotnet build picks the wrong SDK on the Ubuntu image

0xced's Avatar

0xced

08 Nov, 2020 03:58 PM

I am a bit perplexed by this. I have a global.json file with this content at the root of my repository:

{
  "$schema": "https://json.schemastore.org/global",
  "sdk": {
    "allowPrerelease": false,
    "rollForward": "latestMinor",
    "version": "3.1"
  }
}

And here is the list of .NET Core SDKs installed by default on the Ubuntu image, as you can see on my failing build:

  • 1.1.14 [/usr/share/dotnet/sdk]
  • 2.1.202 [/usr/share/dotnet/sdk]
  • 2.1.806 [/usr/share/dotnet/sdk]
  • 2.2.402 [/usr/share/dotnet/sdk]
  • 3.0.103 [/usr/share/dotnet/sdk]
  • 3.1.300 [/usr/share/dotnet/sdk]
  • 5.0.100-preview.3.20216.6 [/usr/share/dotnet/sdk]

Then the build is run with this command:

dotnet build "/home/appveyor/projects/six-bankmaster/Six.BankMaster.sln" --configuration Release --verbosity minimal /m /l:"/opt/appveyor/build-agent/msbuild-logger/Appveyor.MSBuildLogger.dll" /p:GeneratePackageOnBuild=false

And it fails with this error, proving that a preview of the .NET Core 5 SDK is used instead of version 3.1 as defined in my global.json file.

/usr/share/dotnet/sdk/5.0.100-preview.3.20216.6/Roslyn/Microsoft.Managed.Core.targets(104,5): error : SourceRoot items must include at least one top-level (not nested) item when DeterministicSourcePaths is true [/home/appveyor/projects/six-bankmaster/tests/Six.BankMaster.Tests.csproj]

Am I doing something wrong or is this a bug with the .NET Core SDK ? And if this is a bug in the SDK, is there a workaround so that the build doesn't end up using a .NET Core 5 preview SDK ?

  1. 1 Posted by 0xced on 08 Nov, 2020 04:04 PM

    0xced's Avatar

    OK, so using "version": "3.1.300" instead of "version": "3.1" selects the correct SDK. This is quite counterintuitive in my opinion !

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac