dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.65k stars 1.05k forks source link

msbuild sdk resolver should trigger an error msbuild requests an exact version #8236

Open nguerrera opened 7 years ago

nguerrera commented 7 years ago

We have decided that (at least for 15.3/2.0) that only global.json can be used to pin an exact version of the SDK. It cannot be done in the project file. The rationale is that mixing sdk versions across P2P references will just not work, so a "line-up" is needed to fix it across a solution. Fixing it in each project file is error-prone.

Nevertheless, MSBuild has project syntax for both minimum version and exact version: https://github.com/Microsoft/msbuild/blob/9e2254833ced58fd3bb55715e8d3bec8b89addc9/src/Framework/Sdk/SdkReference.cs#L32-L42

When the exact version syntax is used, we should error out and say that we don't support it. We should link to documentation on using minimum version and/or global.json.

This will prevent silently ignoring a typo where user intended minimum version. It will also give us the flexibility to support it in the future without making a breaking change.

@johnbeisner @dsplaisted

nguerrera commented 6 years ago

Leaving this for 3.0. MSBuild has a warning now when you get a version different from what you requested and it says that you can only use one version across a build. It even caches the version per build submission. Doing anything more is breaking.