diff --git a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishToClickOnce.cs b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishToClickOnce.cs index 80ec02bfe065..9b0eaf62d7b2 100644 --- a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishToClickOnce.cs +++ b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishToClickOnce.cs @@ -17,7 +17,22 @@ namespace Microsoft.NET.Publish.Tests { - public class GivenThatWeWantToPublishAClickOnceProject : SdkTest + internal class DotnetEnvironmentTestFixture : IDisposable + { + private readonly string _originalPath; + private const string _PATH_VAR_NAME = "PATH"; + + public DotnetEnvironmentTestFixture() + { + string dotnetRootUnderTest = TestContext.Current.ToolsetUnderTest.DotNetRoot; + _originalPath = Environment.GetEnvironmentVariable(_PATH_VAR_NAME); + Environment.SetEnvironmentVariable(_PATH_VAR_NAME, dotnetRootUnderTest + Path.PathSeparator + _originalPath); + } + + public void Dispose() => Environment.SetEnvironmentVariable(_PATH_VAR_NAME, _originalPath); + } + + public class GivenThatWeWantToPublishAClickOnceProject : SdkTest, IClassFixture { public GivenThatWeWantToPublishAClickOnceProject(ITestOutputHelper log) : base(log) {