From f20cada3e8fa94f62c50bda172cbd30a469bcae0 Mon Sep 17 00:00:00 2001 From: Phil Henning Date: Tue, 18 Nov 2025 15:12:16 -0500 Subject: [PATCH 1/3] Set CFSClean for Centralized Feed Service policy. * blocks nuget.org in CI pipeline. --- azure-pipelines.yml | 2 ++ 1 file changed, 2 insertions(+) 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) From 2f547f051d983187d5334e28ddb70ae114b1a62b Mon Sep 17 00:00:00 2001 From: Phil Henning Date: Tue, 18 Nov 2025 16:05:49 -0500 Subject: [PATCH 2/3] Fix issue with tests and CFS Update the TemporaryFileProviderTest so we can laydown the project file under the artifacts folder. This allows us to pick up the nuget.config in the repo root when restore happens. --- test/Scaffolding/Shared/TemporaryFileProvider.cs | 7 ++++++- .../ProjectContextWriterTests.cs | 14 +++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) 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..103e4c32a 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,7 +97,7 @@ 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); @@ -107,7 +110,7 @@ public void TestProjectContextNullableMissing() [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); + } } } From 3cf152cc8d2d9eae1956df388765630024e1f1fb Mon Sep 17 00:00:00 2001 From: Phil Henning Date: Fri, 12 Dec 2025 14:10:10 -0500 Subject: [PATCH 3/3] Update test, this returns enable now if missing in proj file --- .../VS.Web.CG.MSBuild.Test/ProjectContextWriterTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Scaffolding/VS.Web.CG.MSBuild.Test/ProjectContextWriterTests.cs b/test/Scaffolding/VS.Web.CG.MSBuild.Test/ProjectContextWriterTests.cs index 103e4c32a..f21bc7720 100644 --- a/test/Scaffolding/VS.Web.CG.MSBuild.Test/ProjectContextWriterTests.cs +++ b/test/Scaffolding/VS.Web.CG.MSBuild.Test/ProjectContextWriterTests.cs @@ -103,7 +103,7 @@ public void TestProjectContextNullableMissing() var path = Path.Combine(fileProvider.Root, MsBuildProjectStrings.RootProjectName3); var projectContext = GetProjectContext(path, true); - Assert.Null(projectContext.Nullable); + Assert.Equal("enable", projectContext.Nullable); } }