-
-
Save radical/27ab744e235badd5f7b24dbfc85ec9af to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/Shared/FileMatcher.cs b/src/Shared/FileMatcher.cs | |
index 3ad7eb36..e8230405 100644 | |
--- a/src/Shared/FileMatcher.cs | |
+++ b/src/Shared/FileMatcher.cs | |
@@ -190,6 +190,11 @@ namespace Microsoft.Build.Shared | |
// look in current directory if no path specified | |
string dir = ((path.Length == 0) ? s_thisDirectory : path); | |
+ if (!Directory.Exists(dir)) | |
+ { | |
+ return Array.Empty<string>(); | |
+ } | |
+ | |
// get all files in specified directory, unless a file-spec has been provided | |
string[] files = (filespec == null) | |
? Directory.GetFiles(dir) | |
@@ -244,13 +249,19 @@ namespace Microsoft.Build.Shared | |
{ | |
string[] directories = null; | |
+ var dirToUse = (path.Length == 0) ? s_thisDirectory : path; | |
+ if (!Directory.Exists(dirToUse)) | |
+ { | |
+ return Array.Empty<string>(); | |
+ } | |
+ | |
if (pattern == null) | |
{ | |
- directories = Directory.GetDirectories((path.Length == 0) ? s_thisDirectory : path); | |
+ directories = Directory.GetDirectories(dirToUse); | |
} | |
else | |
{ | |
- directories = Directory.GetDirectories((path.Length == 0) ? s_thisDirectory : path, pattern); | |
+ directories = Directory.GetDirectories(dirToUse, pattern); | |
} | |
// Subdirectories in the current directory are coming back with a ".\" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment