MSBuildLocator fails in macOS GUI apps due to missing /usr/local/share/dotnet in PATH
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- csharp
- Domain
- build-system
Research direction
Start with Microsoft.Build.Locator.DotNetSdkLocationHelper.ResolveDotnetPathCandidates and the environment-variable probing described in the stack trace. Reproduce the launchd scenario using a macOS GUI app, then verify that MSBuildLocator can find an installed .NET SDK without inheriting the shell PATH; the issue does not name a test file.
Written by the indexing model from the issue text.
Description
On macOS, GUI applications launched via launchd (such as apps opened from Finder or the Dock) do not inherit the shell's PATH environment variable. As a result, the directory /usr/local/share/dotnet is typically missing from the PATH, causing MSBuildLocator to fail to find .NET installations.
System.InvalidOperationException: Path to dotnet executable is not set. The probed variables are: DOTNET_ROOT, DOTNET_HOST_PATH, DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR and PATH. Make sure, that at least one of the listed variables points to the existing dotnet executable.
at Microsoft.Build.Locator.DotNetSdkLocationHelper.ResolveDotnetPathCandidates()
at Microsoft.Build.Locator.DotNetSdkLocationHelper.<>c.<.cctor>b__17_0()
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at Microsoft.Build.Locator.DotNetSdkLocationHelper.<GetInstances>g__GetSdkFromGlobalSettings|5_2(String workingDirectory)
at Microsoft.Build.Locator.DotNetSdkLocationHelper.GetInstances(String workingDirectory, Boolean allowQueryAllRuntimes, Boolean allowAllDotnetLocations)+MoveNext()
My current workaround:
private static void FixMacosPath()
{
var processStartInfo = new ProcessStartInfo
{
FileName = "/bin/zsh",
ArgumentList = { "-l", "-c", "printenv PATH" },
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
};
using var process = Process.Start(processStartInfo);
var output = process!.StandardOutput.ReadToEnd().Trim();
process.WaitForExit();
Environment.SetEnvironmentVariable("PATH", output, EnvironmentVariableTarget.Process);
}
Ideally the shell PATH, or another relevant environment variable would be set for GUI apps.
- Dominant language
- C#
- Stars
- 262
- Forks
- 91
- Avg merge
- 11d 22h
- Merged PRs (30d)
- 3
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/MSBuildLocator
-
Difficulty 3/5 1-2 days Newbie friendliness 52/100
microsoft/MSBuildLocator#390 · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 64/100
microsoft/MSBuildLocator#389 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
microsoft/MSBuildLocator#380 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
microsoft/MSBuildLocator#377 ·
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
microsoft/MSBuildLocator#371 · 1 comment ·
All issues in microsoft/MSBuildLocator
Similar issues
-
type/automation type/tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
t/bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
ci-failure-cause test-failure
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
area:auth FE mvp P3
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
klasolsson81/jobbliggaren#1788 ·