Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/ProjectTemplates/Shared/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -167,7 +169,13 @@ internal async Task RunDotNetPublishAsync(IDictionary<string, string> 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);
Expand All @@ -190,7 +198,13 @@ internal async Task RunDotNetBuildAsync(IDictionary<string, string> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 13 additions & 1 deletion src/Shared/Process/ProcessEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string> envVars = null, TimeSpan? timeout = default)
public static ProcessEx Run(
ITestOutputHelper output,
string workingDirectory,
string command,
string args = null,
IDictionary<string, string> envVars = null,
TimeSpan? timeout = default,
string envVarToRemove = null)
{
var startInfo = new ProcessStartInfo(command, args)
{
Expand All @@ -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")))
Expand Down
Loading