question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

global.json not enforcing SDK version

See original GitHub issue

Attempting to move dotnet/roslyn to SDK 2.0. My first step was to use global.json to enforce that 2.0 was being used to prevent bad behavior when a developer accidentally build on an environment with only 1.X installed.

I tried using global.json to achieve this by adding the following file to the root of my repo:

{
  "sdk": {
    "version": "2.0.0"
  }
}

I then built and everything succeeded. This is contrary to my expectations because I don’t have the 2.0 SDK installed on this machine. I do have dotnet on the path and MSBuild 15.3 but no 2.0 build of the SDK.

Why did this work? I really can’t understand the function of global.json if it doesn’t prevent this build from functioning.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
jaredparcommented, Aug 3, 2017

Sounds like global.json is only useful then when:

  • At least MSBuild 15.3 is installed
  • dotnet 2.0.0 is installed

Lacking that it’s just a file on disk that is ignored by the build.

If that’s the case then why does our only documentation of the file display it restricting to the 1.0.0 SDK? Doesn’t seem very useful.

0reactions
nguerreracommented, May 23, 2019

I believe this was covered in the documentation added for https://github.com/dotnet/docs/issues/2902

Read more comments on GitHub >

github_iconTop Results From Across the Web

NETSDK1141: Unable to resolve the .NET SDK version as ...
Cause · The SDK version in the global.json file is incorrectly specified. · The SDK version specified in the global.json file was not...
Read more >
global.json not work or not recognized by my .NET project
The global.json setting "sdk" selects the SDK, not the target platform. That means it chooses (basically) the compiler to use, not the ...
Read more >
Fixing: Unable to locate the .NET Core SDK. Check that it is ...
NET Core SDK. Check that it is installed and that the version specified in global.json (if any) matches the installed version.
Read more >
Unhelpful error message when global.json points to .NET ...
json file in it that pins to an SDK version that does not exist on the target machine, Visual Studio fails to load...
Read more >
How to avoid global.json version conflicts in Azure DevOps
NET SDK version set in the global.json, you need to either always keep the tooling in sync (which at least for us was...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found