Skip to content

Commit 62b690b

Browse files
authored
Make folder if needed for MSBUILDDEBUGPATH (#7791)
When using MSBuildDebugEngine, we recommend specifying MSBUILDDEBUGPATH. If you specify somewhere we can't write to, we have fallbacks. However, if you specify somewhere we can write to but doesn't yet exist, we can't write to it yet, so that part returns false, and we go on to the fallbacks. This makes the folder explicitly if we can, making it return true if we can write to a directory, but it doesn't yet exist. Fixes #7752
1 parent 0318d9f commit 62b690b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/Shared/FileUtilities.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ internal static bool CanWriteToDirectory(string directory)
174174
try
175175
{
176176
string testFilePath = Path.Combine(directory, $"MSBuild_{Guid.NewGuid().ToString("N")}_testFile.txt");
177+
FileInfo file = new(testFilePath);
178+
file.Directory.Create(); // If the directory already exists, this method does nothing.
177179
File.WriteAllText(testFilePath, $"MSBuild process {Process.GetCurrentProcess().Id} successfully wrote to file.");
178180
File.Delete(testFilePath);
179181
return true;

0 commit comments

Comments
 (0)