sdk
sdk copied to clipboard
Allow dotnet commands to bypass the global.json version check
Sometimes users or more importantly CI servers don't have the correct dotnet SDK installed.
We wrote FAKE install scripts that would take care of installing the correct SDK version during the build. Unfortunately even dotnet tool
requires to have exactly the specified version available. So we have chicken and egg situation. We can't download the tool that would fix the SDK version conflict since the downloader already requires the correct SDK. What I'd like to see is:
-
dotnet tool install --any-sdk-version --tool-path tools fake-cli
-
tools\fake.exe build --target Build
- --> FAKE runs and installs the correct SDK with it's own functionality
As written above 1) is already failing since dotnet tool requires the SDK version from global.json
Workaround
- Install
fake-cli
package with Paket or NuGet -
dotnet "packages\build\Fake-Cli\tools\netcoreapp2.1\any\fake-cli.dll" build --target Build
Note how this dotnet command does not requirer the correct SDK version.
- Install
fake-cli
package with Paket or NuGet
I haven't tested it but I'd say dotnet nuget
probably fails as well. Therefore only nuget.exe
is an option.
Regarding the cli option: I'd suggest --ignore-global-json
or something like that. And I'd suggest this option to be available for all commands (not just install
).
even worse:
dotnet --version
A compatible SDK version for global.json version: [2.2.300] from [D:\...\global.json] was not found Did you mean to run dotnet SDK commands? Please install dotnet SDK from: https://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
you can't even get the version of what would be available.
cc @KathleenDollard
@KathleenDollard @livarcocc is there some official recommendations on if people should use the global.json at all?
Possibly related: https://github.com/dotnet/sdk/issues/10603
The source-built SDK does something to bypass the global.json files across the board, but I can't for the life of me figure out what.
We had a few dotnet commands that were allowed to run a different SDK than the one specified in global.json, and used the following work around
mv global.json disabled-global.json
[Some dotnet command allowed any sdk, for example dotnet tool install]
mv disabled-global.json global.json
[Some dotnet command not allowed any sdk, for example dotnet build]