Skip to content

Commit

Permalink
Make folder if needed for MSBUILDDEBUGPATH (#7791)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Forgind authored Jul 8, 2022
1 parent 0318d9f commit 62b690b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Shared/FileUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ internal static bool CanWriteToDirectory(string directory)
try
{
string testFilePath = Path.Combine(directory, $"MSBuild_{Guid.NewGuid().ToString("N")}_testFile.txt");
FileInfo file = new(testFilePath);
file.Directory.Create(); // If the directory already exists, this method does nothing.
File.WriteAllText(testFilePath, $"MSBuild process {Process.GetCurrentProcess().Id} successfully wrote to file.");
File.Delete(testFilePath);
return true;
Expand Down

0 comments on commit 62b690b

Please sign in to comment.