.NET: use a preview version in your global.json

.NET: use a preview version in your global.json

We are currently in the preview phase of .NET 9, which releases in Nov 2024 - and if you want to test it extensively like I do, store the preview version in the global configuration global.json. But how do you have to define the version here for it to work?

Wrong

Intuitively, you would assume that you can simply copy and paste the version - but that would be too simple for the .NET world.

{
  "sdk": {
    "version": "9.0.100-preview.5.24306.7"
  }
}

Correct

The correct definition is the pure preview version specification.

{
  "sdk": {
    "version": "9.0.100-preview.5"
  }
}