Skip to content

Commit 29182b0

Browse files
committed
Explicitly throw a FileNotFoundException if the exe file does not exist instead of relying on Process.Start() to do it, since it doesn't say anything about which file it can't find (which makes debugging very hard).
1 parent 4c267f4 commit 29182b0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

GitVersionCore/Helpers/ProcessHelper.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ public static int Run(Action<string> output, Action<string> errorOutput, TextRea
3636
if (output == null)
3737
throw new ArgumentNullException("output");
3838

39+
workingDirectory = workingDirectory ?? Environment.CurrentDirectory;
40+
var exePath = Path.Combine(workingDirectory, exe);
41+
42+
if (!File.Exists(exePath))
43+
throw new FileNotFoundException(String.Format("The executable file '{0}' does not exist.", exePath), exePath);
44+
3945
var psi = new ProcessStartInfo
4046
{
4147
UseShellExecute = false,
@@ -45,7 +51,7 @@ public static int Run(Action<string> output, Action<string> errorOutput, TextRea
4551
WindowStyle = ProcessWindowStyle.Hidden,
4652
CreateNoWindow = true,
4753
ErrorDialog = false,
48-
WorkingDirectory = workingDirectory ?? Environment.CurrentDirectory,
54+
WorkingDirectory = workingDirectory,
4955
FileName = exe,
5056
Arguments = args
5157
};

0 commit comments

Comments
 (0)