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")
|
||||
.Split(s_pathSeparator)
|
||||
.Select(p => p.Trim(s_quote))
|
||||
.Where(p => !string.IsNullOrWhiteSpace(p))
|
||||
.Select(p => ExpandTildeSlash(p)));
|
||||
|
||||
_searchPaths = searchPaths;
|
||||
|
|
|
@ -33,6 +33,11 @@ namespace Microsoft.DotNet.ShellShim
|
|||
|
||||
var existingUserEnvPath = Environment.GetEnvironmentVariable(PathName, EnvironmentVariableTarget.User);
|
||||
|
||||
if (existingUserEnvPath.EndsWith(';'))
|
||||
{
|
||||
existingUserEnvPath = existingUserEnvPath.Substring(0, (existingUserEnvPath.Length - 1));
|
||||
}
|
||||
|
||||
Environment.SetEnvironmentVariable(
|
||||
PathName,
|
||||
$"{existingUserEnvPath};{_packageExecutablePath}",
|
||||
|
|
Loading…
Reference in a new issue