Skip to content

[wasm] Remove dead BuildOnlyAfterPublish option from Wasm.Build.Tests - #137370

Merged
lewing merged 2 commits into
mainfrom
lewing-wbt-buildonlyafterpublish-fix
Nov 12, 2026
Merged

lewing merged 2 commits into
mainfrom
lewing-wbt-buildonlyafterpublish-fix

Conversation

@lewing

@lewing lewing commented Nov 11, 2026

Copy link
Copy Markdown
Member

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.

BuildProjectWithoutAssert appended -p:WasmBuildOnlyAfterPublish=true via
LINQ Enumerable.Append on a List<string>, discarding the result, so the
flag has not been passed since #89360. It is also redundant: publish runs
with _IsPublishing=true, and WasmApp.Common.targets and
BrowserWasmApp.CoreCLR.targets already default WasmBuildOnlyAfterPublish
to true in that case. Remove the branch and the unused
PublishOptions.BuildOnlyAfterPublish option.

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.

lewing added a commit that referenced this pull request Nov 11, 2026
…BuildAndPublish (#137368)

`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.

---------

Co-authored-by: Copilot App <[email protected]>
@lewing
lewing enabled auto-merge (squash) November 12, 2026 17:10
@lewing

lewing commented Nov 12, 2026

Copy link
Copy Markdown
Member Author

/ba-g failure is wbt timeout

@lewing
lewing merged commit bd67423 into main Nov 12, 2026
36 of 38 checks passed
@lewing
lewing deleted the lewing-wbt-buildonlyafterpublish-fix branch November 12, 2026 18:47
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 13, 2026
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