Skip to content

Commit ba46f06

Browse files
authored
Merge pull request #728 from dotnet/fixNRE
Fix NullReferenceException thrown when PATH is empty/missing
2 parents d66ac53 + be4a5a7 commit ba46f06

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Nerdbank.GitVersioning.Tasks/ContextAwareTask.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ where outerProperty.SetMethod is not null && outerProperty.GetMethod is not null
5656
// On .NET Framework (on Windows), we find native binaries by adding them to our PATH.
5757
if (this.UnmanagedDllDirectory is not null)
5858
{
59-
string pathEnvVar = Environment.GetEnvironmentVariable("PATH");
59+
string pathEnvVar = Environment.GetEnvironmentVariable("PATH") ?? string.Empty;
6060
string[] searchPaths = pathEnvVar.Split(Path.PathSeparator);
6161
if (!searchPaths.Contains(this.UnmanagedDllDirectory, StringComparer.OrdinalIgnoreCase))
6262
{

0 commit comments

Comments
 (0)