diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1b51116d0..f44e9e0c7 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -28,6 +28,8 @@ resources: extends: template: azure-pipelines/MicroBuild.1ES.Official.yml@MicroBuildTemplate parameters: + settings: + networkIsolationPolicy: Permissive,CFSClean sdl: sourceAnalysisPool: name: $(DncEngInternalBuildPool) diff --git a/test/Scaffolding/Shared/TemporaryFileProvider.cs b/test/Scaffolding/Shared/TemporaryFileProvider.cs index 2e6983599..52ff94daa 100644 --- a/test/Scaffolding/Shared/TemporaryFileProvider.cs +++ b/test/Scaffolding/Shared/TemporaryFileProvider.cs @@ -10,8 +10,13 @@ namespace Microsoft.VisualStudio.Web.CodeGeneration { internal class TemporaryFileProvider : PhysicalFileProvider { + public TemporaryFileProvider(string tmpPathRoot) + : base(Directory.CreateDirectory(Path.Combine(tmpPathRoot, "tmpFiles", Guid.NewGuid().ToString())).FullName) + { + } + public TemporaryFileProvider() - : base(Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), "tmpfiles", Guid.NewGuid().ToString())).FullName) + : this(Path.GetTempPath()) { } diff --git a/test/Scaffolding/VS.Web.CG.MSBuild.Test/ProjectContextWriterTests.cs b/test/Scaffolding/VS.Web.CG.MSBuild.Test/ProjectContextWriterTests.cs index 18c528b62..f21bc7720 100644 --- a/test/Scaffolding/VS.Web.CG.MSBuild.Test/ProjectContextWriterTests.cs +++ b/test/Scaffolding/VS.Web.CG.MSBuild.Test/ProjectContextWriterTests.cs @@ -2,9 +2,12 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.CodeDom; using System.IO; using System.Linq; +using System.Reflection; using System.Runtime.InteropServices; +using Microsoft.Build.Tasks; using Microsoft.DotNet.Scaffolding.Shared; using Microsoft.VisualStudio.Web.CodeGeneration.Msbuild; using Xunit; @@ -80,7 +83,7 @@ public void TestProjectContextWithReferencedModel() [Fact] public void TestProjectContextNullableDisabled() { - using (var fileProvider = new TemporaryFileProvider()) + using (var fileProvider = new TemporaryFileProvider(GetCurrentAssemblyPath())) { new MsBuildProjectSetupHelper().SetupCodeGenerationProjectNullableDisabled(fileProvider, _outputHelper); var path = Path.Combine(fileProvider.Root, MsBuildProjectStrings.RootProjectName2); @@ -94,20 +97,20 @@ public void TestProjectContextNullableDisabled() [Fact] public void TestProjectContextNullableMissing() { - using (var fileProvider = new TemporaryFileProvider()) + using (var fileProvider = new TemporaryFileProvider(GetCurrentAssemblyPath())) { new MsBuildProjectSetupHelper().SetupCodeGenerationProjectNullableMissing(fileProvider, _outputHelper); var path = Path.Combine(fileProvider.Root, MsBuildProjectStrings.RootProjectName3); var projectContext = GetProjectContext(path, true); - Assert.Null(projectContext.Nullable); + Assert.Equal("enable", projectContext.Nullable); } } [Fact] public void TestProjectContextNullableEnabled() { - using (var fileProvider = new TemporaryFileProvider()) + using (var fileProvider = new TemporaryFileProvider(GetCurrentAssemblyPath())) { new MsBuildProjectSetupHelper().SetupCodeGenerationProjectNullableEnabled(fileProvider, _outputHelper); var path = Path.Combine(fileProvider.Root, MsBuildProjectStrings.RootProjectName3); @@ -171,5 +174,10 @@ public void GetXmlKeyValueTests() Assert.Equal("", emptyValue, ignoreCase: true); Assert.Equal("", nullValue, ignoreCase: true); } + + private static string GetCurrentAssemblyPath() + { + return Path.GetDirectoryName(typeof(ProjectContextWriterTests).GetType().Assembly.Location); + } } }