You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using Fake.DotNet.DotNet.exec without overriding Options.DotNetCliPath,
it "tries to take current global.json into account and tries to find the correct installation".
If global.json specifies a version of dotnet that is installed on windows, it will use the windows exe. Even if that version is also installed in wsl.
Repro steps
make a global.json file with a version of dotnet specified which is installed on windows
run dotnet fsi from WSL
run
#r "nuget: Fake.DotNet.Cli"openFake.DotNet
DotNet.exec id "--info""";;
Expected behavior
Output should be the same as running dotnet --info from WSL. Runtime Environment similar is
Runtime Environment:
OS Name: ubuntu
OS Version: 20.04
OS Platform: Linux
RID: ubuntu.20.04-x64
Base Path: /usr/share/dotnet/sdk/5.0.201/
Actual behavior
Output is the same as running dotnet --info from windows. Runtime Environment is
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19041
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\5.0.101\
Known workarounds
change version in global.json to a version which isn't installed on windows, or
override DotNetCliPath in the exec options
Related information
Windows 10 with Ubuntu 20.04 on WSL2
.NET 5
Version of FAKE (4.X, 5.X)
Cause and fix
The default DotNetCliPath is found by taking a sequence of possible paths and then finding the first one that has the correct version (from global.json) available. This sequence of paths includes ProcessUtils.findFilesOnPath "dotnet" and so includes both /usr/bin/dotnet and /mnt/c/Program Files/dotnet/dotnet.exe. If none of them have the correct version it will just fallback to "dotnet".
From here there are two problems. Firstly, the way it checks for installed versions does not work when the path /usr/bin/dotnet is a symlink to /usr/share/dotnet/dotnet. Secondly, it should NEVER use dotnet.exe regardless because doing so can lead to a myriad of problems when you are expecting everything to be running in linux.
The suggested fix is to exclude .exe files from findPossibleDotnetCliPaths and make it follow symlinks while checking installed versions (is that possible?) or check versions some other way,
Description
When using
Fake.DotNet.DotNet.exec
without overridingOptions.DotNetCliPath
,it "tries to take current
global.json
into account and tries to find the correct installation".If
global.json
specifies a version of dotnet that is installed on windows, it will use the windows exe. Even if that version is also installed in wsl.Repro steps
global.json
file with a version of dotnet specified which is installed on windowsdotnet fsi
from WSLExpected behavior
Output should be the same as running
dotnet --info
from WSL. Runtime Environment similar isActual behavior
Output is the same as running
dotnet --info
from windows. Runtime Environment isKnown workarounds
global.json
to a version which isn't installed on windows, orDotNetCliPath
in the exec optionsRelated information
Cause and fix
The default
DotNetCliPath
is found by taking a sequence of possible paths and then finding the first one that has the correct version (fromglobal.json
) available. This sequence of paths includesProcessUtils.findFilesOnPath "dotnet"
and so includes both/usr/bin/dotnet
and/mnt/c/Program Files/dotnet/dotnet.exe
. If none of them have the correct version it will just fallback to "dotnet".From here there are two problems. Firstly, the way it checks for installed versions does not work when the path
/usr/bin/dotnet
is a symlink to/usr/share/dotnet/dotnet
. Secondly, it should NEVER usedotnet.exe
regardless because doing so can lead to a myriad of problems when you are expecting everything to be running in linux.The suggested fix is to exclude .exe files from
findPossibleDotnetCliPaths
and make it follow symlinks while checking installed versions (is that possible?) or check versions some other way,https://github.com/fsharp/FAKE/blob/5cda218b2a0aa89053a02229fac78d610e4efe67/src/app/Fake.DotNet.Cli/DotNet.fs#L539-L551
The text was updated successfully, but these errors were encountered: