Remove empty PATH in path resolver (#8943)
This commit is contained in:
parent
5983fa1a2c
commit
a67d1c6e06
2 changed files with 6 additions and 0 deletions
|
@ -47,6 +47,7 @@ namespace Microsoft.DotNet.Cli.Utils
|
||||||
.GetEnvironmentVariable("PATH")
|
.GetEnvironmentVariable("PATH")
|
||||||
.Split(s_pathSeparator)
|
.Split(s_pathSeparator)
|
||||||
.Select(p => p.Trim(s_quote))
|
.Select(p => p.Trim(s_quote))
|
||||||
|
.Where(p => !string.IsNullOrWhiteSpace(p))
|
||||||
.Select(p => ExpandTildeSlash(p)));
|
.Select(p => ExpandTildeSlash(p)));
|
||||||
|
|
||||||
_searchPaths = searchPaths;
|
_searchPaths = searchPaths;
|
||||||
|
|
|
@ -33,6 +33,11 @@ namespace Microsoft.DotNet.ShellShim
|
||||||
|
|
||||||
var existingUserEnvPath = Environment.GetEnvironmentVariable(PathName, EnvironmentVariableTarget.User);
|
var existingUserEnvPath = Environment.GetEnvironmentVariable(PathName, EnvironmentVariableTarget.User);
|
||||||
|
|
||||||
|
if (existingUserEnvPath.EndsWith(';'))
|
||||||
|
{
|
||||||
|
existingUserEnvPath = existingUserEnvPath.Substring(0, (existingUserEnvPath.Length - 1));
|
||||||
|
}
|
||||||
|
|
||||||
Environment.SetEnvironmentVariable(
|
Environment.SetEnvironmentVariable(
|
||||||
PathName,
|
PathName,
|
||||||
$"{existingUserEnvPath};{_packageExecutablePath}",
|
$"{existingUserEnvPath};{_packageExecutablePath}",
|
||||||
|
|
Loading…
Reference in a new issue