sdk icon indicating copy to clipboard operation
sdk copied to clipboard

Allow dotnet commands to bypass the global.json version check

Open forki opened this issue 5 years ago • 14 comments

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:

  1. dotnet tool install --any-sdk-version --tool-path tools fake-cli
  2. tools\fake.exe build --target Build
  3. --> 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

  1. Install fake-cli package with Paket or NuGet
  2. 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.

forki avatar Jun 06 '19 06:06 forki

  1. 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).

matthid avatar Jun 06 '19 06:06 matthid

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.

forki avatar Jun 06 '19 06:06 forki

cc @KathleenDollard

livarcocc avatar Jun 07 '19 16:06 livarcocc

@KathleenDollard @livarcocc is there some official recommendations on if people should use the global.json at all?

forki avatar Jun 12 '19 06:06 forki

Possibly related: https://github.com/dotnet/sdk/issues/10603

AnthonyMastrean avatar Feb 05 '20 00:02 AnthonyMastrean

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.

mid-kid avatar May 22 '21 19:05 mid-kid

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]

dignite avatar Sep 22 '22 11:09 dignite