Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR filters the resolved paths for dotnet by OS in
Fake.DotNet.Cli
. Fixes #2573As reported in the issue. If a dotnet version is specified in a
global.json
file and that version is not installed on WSL but on Windows, theFake.DotNet.Cli
will use dotnet installed on Windows -C:\Program Files\dotnet\sdk\5.0.201\
The issue with this is when it tries to find possible paths it doesn't check for OS combatapility. This PR checks for resolved path to have the intended file suffixed with it. So on WSL and Unix, it will be
dotnet
and Windows resolved paths will be excluded. Likewise, if it was on Windows, it will bedotnet.exe
, and Unix and WSL paths will be excluded.For the
userInstalldir
andsystemInstalldir
they follow the OS compatibility by setting path by executing OS. So no changes need to be done regarding them. The fault paths are a result of resolving them from environment variables that are not filtered by OS.Using the following
fsi
snippet from issue:And the following
global.json
:I tested it out and got the following results:
On WSL
Installed SDKs:
The result, the sequence is resulting paths that
Fake.DotNet.Cli
has resolved to:And I have
/usr/bin/dotnet
a symlink to/usr/share/dotnet/dotnet
On Windows
Installed SDKs:
The result, the sequence is resulting paths that
Fake.DotNet.Cli
has resolved to:I have 5.0.103 installed on Windows, I set it on
global.json
and got the following result on WSL:No runtime environment has been listed.