From 5e916d1acf46583c4068f11f41b8d4f7ef4922a4 Mon Sep 17 00:00:00 2001 From: Jeff Kluge Date: Mon, 23 Oct 2023 13:18:30 -0700 Subject: [PATCH] Fix unit tests that fail due to current directory being deleted (#497) --- src/Shared/MSBuildSdkTestBase.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Shared/MSBuildSdkTestBase.cs b/src/Shared/MSBuildSdkTestBase.cs index 3296d2e4..382f84fe 100644 --- a/src/Shared/MSBuildSdkTestBase.cs +++ b/src/Shared/MSBuildSdkTestBase.cs @@ -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() { @@ -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))