diff --git a/src/Microsoft.ComponentDetection.Detectors/nuget/NuGetComponentDetector.cs b/src/Microsoft.ComponentDetection.Detectors/nuget/NuGetComponentDetector.cs index eba09e5c7..f852b43f8 100644 --- a/src/Microsoft.ComponentDetection.Detectors/nuget/NuGetComponentDetector.cs +++ b/src/Microsoft.ComponentDetection.Detectors/nuget/NuGetComponentDetector.cs @@ -254,6 +254,11 @@ private IList GetRepositoryPathsFromNugetConfig(IComponentStream /// True if path is valid, otherwise it retuns false. private bool IsValidPath(string potentialPath) { + if (potentialPath == null) + { + return false; + } + FileInfo fileInfo = null; try @@ -265,11 +270,6 @@ private bool IsValidPath(string potentialPath) return false; } - if (potentialPath == null) - { - return false; - } - return fileInfo.Exists || fileInfo.Directory.Exists; } }