-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only set debug path when MSBuildDebugEngine is set (#6792)
In #6639 I thought it would be a good idea to always expose exceptions by always setting msbuild's debug path, fallbacking to the current working directory. But that's a breaking change. Also, some processes (like VS helpers) do not propagate the user's CWD and thus end up writing under Program Files which fails with permission exceptions. So only set the debug path to the current working directory when `MSBuildDebugEngine` is set.
- Loading branch information
Showing
3 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using Microsoft.Build.Shared; | ||
using Shouldly; | ||
using Xunit; | ||
|
||
namespace Microsoft.Build.UnitTests | ||
{ | ||
public class DebugUtils_Tests | ||
{ | ||
[Fact] | ||
public void DumpExceptionToFileShouldWriteInTempPathByDefault() | ||
{ | ||
Directory.GetFiles(Path.GetTempPath(), "MSBuild_*failure.txt").ShouldBeEmpty(); | ||
|
||
string[] exceptionFiles = null; | ||
|
||
try | ||
{ | ||
ExceptionHandling.DumpExceptionToFile(new Exception("hello world")); | ||
exceptionFiles = Directory.GetFiles(Path.GetTempPath(), "MSBuild_*failure.txt"); | ||
} | ||
finally | ||
{ | ||
exceptionFiles.ShouldNotBeNull(); | ||
exceptionFiles.ShouldHaveSingleItem(); | ||
|
||
var exceptionFile = exceptionFiles.First(); | ||
File.ReadAllText(exceptionFile).ShouldContain("hello world"); | ||
File.Delete(exceptionFile); | ||
} | ||
} | ||
} | ||
} |
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
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