Skip to content

Commit

Permalink
Update PlatformsFactory.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
ssaattww authored Jan 26, 2024
1 parent eff3c03 commit b6f1ea0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/RoslynPad.Common.UI/PlatformsFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@ private IEnumerable<ExecutionPlatform> GetNetFrameworkVersions()
return (_dotnetExe, _sdkPath);
}

string[] dotnetPaths;
string?[] dotnetPaths = [Environment.GetEnvironmentVariable("DOTNET_ROOT")];
string dotnetExe;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
dotnetPaths = [Path.Combine(Environment.GetEnvironmentVariable("ProgramW6432")!, "dotnet")];
dotnetPaths ??= [Path.Combine(Environment.GetEnvironmentVariable("ProgramW6432")!, "dotnet")];
dotnetExe = "dotnet.exe";
}
else
{
dotnetPaths = ["/usr/lib64/dotnet", "/usr/share/dotnet", "/usr/local/share/dotnet", Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".dotnet")];
dotnetPaths ??= ["/usr/lib64/dotnet", "/usr/share/dotnet", "/usr/local/share/dotnet", Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".dotnet")];
dotnetExe = "dotnet";
}

Expand Down

1 comment on commit b6f1ea0

@ssaattww
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script
When installing the sdk using dotnet-script, the default installation destination is
For Windows, "%LocalAppData%\Microsoft\dotnet".
For Linux or macOS, "$HOME/.dotnet".
for Linux and macOS.
Therefore, searching only under programfiles is not sufficient.

https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-environment-variables
If dotnet is installed in an existing location other than, for example, "Program Files," it can be handled by defining the "DOTNET_ROOT" and "DOTNET_HOST_PATH" environment variables.

So, check "DOTNET_ROOT" in "PlatformsFactory.cs" and correspond to the sdk installed in a location other than the default location.

Please sign in to comment.