Skip to content

Commit

Permalink
Fix UniGetUI not detecting certain executables present on system path…
Browse files Browse the repository at this point in the history
… but not on user (fix #2886, related to 2298)
  • Loading branch information
marticliment committed Feb 10, 2025
1 parent f4e466f commit 5f396ee
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<WindowsSdkPackageVersion>10.0.26100.56</WindowsSdkPackageVersion>
<WindowsSdkPackageVersion>10.0.26100.57</WindowsSdkPackageVersion>
<SdkVersion>8.0.405</SdkVersion>
<Authors>Martí Climent and the contributors</Authors>
<PublisherName>Martí Climent</PublisherName>
Expand Down
7 changes: 7 additions & 0 deletions src/UniGetUI.Core.Tools/Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ public static Tuple<bool, string> Which(string command, bool updateEnv = true)
{
command = command.Replace(";", "").Replace("&", "").Trim();
Logger.Debug($"Begin \"which\" search for command {command}");

string PATH = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.User) + ";";
PATH += Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Machine) + ";";
PATH += Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Process);
PATH = PATH.Replace(";;", ";").Trim(';');

Process process = new()
{
StartInfo = new ProcessStartInfo
Expand All @@ -106,6 +112,7 @@ public static Tuple<bool, string> Which(string command, bool updateEnv = true)
{
process.StartInfo = UpdateEnvironmentVariables(process.StartInfo);
}
process.StartInfo.Environment["PATH"] = PATH;

try
{
Expand Down

0 comments on commit 5f396ee

Please sign in to comment.