Skip to content

Commit

Permalink
Fix unit tests that fail due to current directory being deleted (#497)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffkl authored Oct 23, 2023
1 parent c80b034 commit 5e916d1
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Shared/MSBuildSdkTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace Microsoft.Build.UnitTests.Common
public abstract class MSBuildSdkTestBase : MSBuildTestBase, IDisposable
{
private readonly string _testRootPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
private readonly string _previousCurrentDirectory = Environment.CurrentDirectory;

public MSBuildSdkTestBase()
{
Expand Down Expand Up @@ -61,6 +62,7 @@ protected DirectoryInfo CreateFiles(string directoryName, params string[] files)

protected virtual void Dispose(bool disposing)
{
Environment.CurrentDirectory = _previousCurrentDirectory;
if (disposing)
{
if (Directory.Exists(TestRootPath))
Expand Down

0 comments on commit 5e916d1

Please sign in to comment.