diff --git a/src/ProjectTemplates/Shared/Project.cs b/src/ProjectTemplates/Shared/Project.cs index 35d55dc91c03..7da096d392fd 100644 --- a/src/ProjectTemplates/Shared/Project.cs +++ b/src/ProjectTemplates/Shared/Project.cs @@ -20,6 +20,8 @@ public class Project : IDisposable { private const string _urlsNoHttps = "http://127.0.0.1:0"; private const string _urls = "http://127.0.0.1:0;https://127.0.0.1:0"; + // Generated projects run with a copied SDK. Do not let the parent MSBuild process redirect that host back to the repository SDK. + private const string _msBuildSdksPathEnvironmentVariable = "MSBuildSDKsPath"; public static string ArtifactsLogDir { @@ -167,7 +169,13 @@ internal async Task RunDotNetPublishAsync(IDictionary packageOpt var restoreArgs = noRestore ? "--no-restore" : null; - using var execution = ProcessEx.Run(Output, TemplateOutputDir, DotNetMuxer.MuxerPathOrDefault(), $"publish {restoreArgs} -c Release /bl {additionalArgs}", packageOptions); + using var execution = ProcessEx.Run( + Output, + TemplateOutputDir, + DotNetMuxer.MuxerPathOrDefault(), + $"publish {restoreArgs} -c Release /bl {additionalArgs}", + packageOptions, + envVarToRemove: _msBuildSdksPathEnvironmentVariable); await execution.Exited; var result = new ProcessResult(execution); @@ -190,7 +198,13 @@ internal async Task RunDotNetBuildAsync(IDictionary packageOptio // Avoid restoring as part of build or publish. These projects should have already restored as part of running dotnet new. Explicitly disabling restore // should avoid any global contention and we can execute a build or publish in a lock-free way - using var execution = ProcessEx.Run(Output, TemplateOutputDir, DotNetMuxer.MuxerPathOrDefault(), $"build --no-restore -c Debug /bl {additionalArgs}", packageOptions); + using var execution = ProcessEx.Run( + Output, + TemplateOutputDir, + DotNetMuxer.MuxerPathOrDefault(), + $"build --no-restore -c Debug /bl {additionalArgs}", + packageOptions, + envVarToRemove: _msBuildSdksPathEnvironmentVariable); await execution.Exited; var result = new ProcessResult(execution); diff --git a/src/ProjectTemplates/test/Templates.Blazor.Tests/BlazorWebTemplateTest.cs b/src/ProjectTemplates/test/Templates.Blazor.Tests/BlazorWebTemplateTest.cs index c8733226724c..a49d5c0d5458 100644 --- a/src/ProjectTemplates/test/Templates.Blazor.Tests/BlazorWebTemplateTest.cs +++ b/src/ProjectTemplates/test/Templates.Blazor.Tests/BlazorWebTemplateTest.cs @@ -19,7 +19,6 @@ public class BlazorWebTemplateTest(ProjectFactoryFixture projectFactory) : Blazo [InlineData(BrowserKind.Chromium, "Auto")] [InlineData(BrowserKind.Chromium, "None", "Individual")] [InlineData(BrowserKind.Chromium, "Server", "None", true)] - [QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/66403")] public async Task BlazorWebTemplate_Works(BrowserKind browserKind, string interactivityOption, string authOption = "None", bool allInteractive = false) { string[] args = allInteractive diff --git a/src/Shared/Process/ProcessEx.cs b/src/Shared/Process/ProcessEx.cs index 41adb92aee92..b7695dc5f09a 100644 --- a/src/Shared/Process/ProcessEx.cs +++ b/src/Shared/Process/ProcessEx.cs @@ -100,7 +100,14 @@ public string Output public object Id => _process.Id; - public static ProcessEx Run(ITestOutputHelper output, string workingDirectory, string command, string args = null, IDictionary envVars = null, TimeSpan? timeout = default) + public static ProcessEx Run( + ITestOutputHelper output, + string workingDirectory, + string command, + string args = null, + IDictionary envVars = null, + TimeSpan? timeout = default, + string envVarToRemove = null) { var startInfo = new ProcessStartInfo(command, args) { @@ -119,6 +126,11 @@ public static ProcessEx Run(ITestOutputHelper output, string workingDirectory, s } } + if (envVarToRemove != null) + { + startInfo.EnvironmentVariables.Remove(envVarToRemove); + } + startInfo.EnvironmentVariables["NUGET_PACKAGES"] = NUGET_PACKAGES; if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("helix")))