Skip to content

Commit 4e73031

Browse files
committed
If FileInfo.Directory returns null, it's most likely because the file's path is C:\GitVersion.log, i.e. to the root of a drive. Since that's a valid use case, null needs to be supported.
1 parent 4b45a15 commit 4e73031

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/GitVersionExe/Program.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ static int VerifyArgumentsAndRun()
113113
return 0;
114114
}
115115

116+
116117
static void ConfigureLogging(Arguments arguments)
117118
{
118119
var writeActions = new List<Action<string>>
@@ -132,11 +133,11 @@ static void ConfigureLogging(Arguments arguments)
132133
var logFileFullPath = Path.GetFullPath(arguments.LogFilePath);
133134
var logFile = new FileInfo(logFileFullPath);
134135

135-
if (logFile.Directory == null)
136-
throw new DirectoryNotFoundException(String.Format("The directory of {0} does not exist.", logFile));
137-
138-
if (!logFile.Directory.Exists)
136+
// NOTE: logFile.Directory will be null if the path is i.e. C:\logfile.log. @asbjornu
137+
if (logFile.Directory != null)
138+
{
139139
logFile.Directory.Create();
140+
}
140141

141142
if (!logFile.Exists)
142143
{

0 commit comments

Comments
 (0)