Skip to content

[wasm] Use BuildProjectWithoutAssert (-nr:false) in MultiClientHostedBuildAndPublish - #137368

Merged
lewing merged 2 commits into
mainfrom
lewing-wbt-multiclienthosted-nr-false
Nov 11, 2026
Merged

lewing merged 2 commits into
mainfrom
lewing-wbt-multiclienthosted-nr-false

Conversation

@lewing

@lewing lewing commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

MiscTests.MultiClientHostedBuildAndPublish called dotnet build/publish directly through DotNetCommand.ExecuteWithCapturedOutput, without -nr:false. Every other Wasm.Build.Tests build goes through BuildTestBase.BuildProjectWithoutAssert, which always passes -nr:false.

This PR switches the test to BuildProjectWithoutAssert with BuildOptions or PublishOptions, so it gets -nr:false (and the helper's binlog output fallback) from the same place as the rest of the suite. For this test, the command line is otherwise unchanged: it runs in the same directory (_projectDir) with the same NUGET_PACKAGES, -p:Configuration, and -bl. The helper's WBTOverrideRuntimePack path doesn't apply, because UseWBTOverridePackTargets is never set to true. The binlog file name changes to the helper's convention.

Why

Over the last 30 days (AzureDevOpsTests), this is the only Wasm.Build.Tests test that fails with:

System.UnauthorizedAccessException: Access to the path 'BlazorMultiClientHosted.dll' (or '.exe') is denied

The failure appeared in 16 Windows main builds, most recently Nov 11. The stack is SharedBuildPerTestClassFixture.RemoveDirectory <- RemoveFromCache <- BuildTestBase.Dispose, so the build itself succeeds and test cleanup fails.

Hypothesis (not proven): Without -nr:false, the build leaves reusable MSBuild worker nodes running, and they keep the server's output locked, so cleanup can't delete the directory. Related: #137297 added a ~9 s cleanup retry and waits for killed ToolCommand processes to exit. The wait doesn't apply here, because this test never starts a long-running process, and idle MSBuild nodes can outlive the retry window. If this test still fails the same way after this change, the hypothesis is wrong.

Related cleanup

While doing this, we found that BuildProjectWithoutAssert discards the result of LINQ Append when it tries to add -p:WasmBuildOnlyAfterPublish=true, so PublishOptions.BuildOnlyAfterPublish never took effect. That's harmless: dotnet publish already defaults WasmBuildOnlyAfterPublish=true. #137370 removes the dead code separately.

Validation

Not built or run locally. I skipped the SDK bootstrap and Wasm.Build.Tests dependency build to save disk space. CI will compile it and run the test.

Note

This PR description and change were generated with GitHub Copilot.

Every other Wasm.Build.Tests build goes through BuildProjectWithoutAssert,
which passes -nr:false. This test invokes dotnet build/publish directly
without it, so reusable MSBuild nodes may outlive the build and keep the
server output locked during fixture cleanup.

Co-authored-by: Copilot App <[email protected]>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Route the build/publish through the shared helper so the test picks up
-nr:false and the binlog output fallback from one place.

Co-authored-by: Copilot App <[email protected]>
@lewing lewing changed the title [wasm] Pass -nr:false in MultiClientHostedBuildAndPublish [wasm] Use BuildProjectWithoutAssert (-nr:false) in MultiClientHostedBuildAndPublish Nov 11, 2026
@lewing
lewing enabled auto-merge (squash) November 11, 2026 18:03
@lewing

lewing commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

/ba-g failure is known

@lewing
lewing merged commit 39f77fd into main Nov 11, 2026
38 of 40 checks passed
@lewing
lewing deleted the lewing-wbt-multiclienthosted-nr-false branch November 11, 2026 20:26
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 12, 2026
lewing added a commit that referenced this pull request Nov 12, 2026
…#137370)

`BuildTestBase.BuildProjectWithoutAssert` tried to add
`-p:WasmBuildOnlyAfterPublish=true` with LINQ `Enumerable.Append` on a
`List<string>`. That returns a new sequence, which was discarded, so the
flag hasn't been passed since #89360 switched the command line from a
`StringBuilder`. The flag is also redundant: `dotnet publish` sets
`_IsPublishing=true`, and `WasmApp.Common.targets` and
`BrowserWasmApp.CoreCLR.targets` already default
`WasmBuildOnlyAfterPublish` to `true` in that case. This PR removes the
dead branch and the unused `PublishOptions.BuildOnlyAfterPublish`
option, so test behavior is unchanged.

`commandLineArgs.AddRange(buildOptions.ExtraMSBuildArgs)` (a `string`)
is left as is. It binds to `AddRange(List<T>, params ReadOnlySpan<T>)`
as one element, and `DotNetCommand` joins the args with spaces, so
values with several arguments still pass correctly.

Related: #137368, which switched `MultiClientHostedBuildAndPublish` to
`BuildProjectWithoutAssert` and surfaced this dead code.

Validation: `Wasm.Build.Tests.csproj` compiled with no errors.
Wasm.Build.Tests were not run locally.

> [!NOTE]
> This PR description was generated with assistance from GitHub Copilot.

Co-authored-by: Copilot App <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants