Skip to content

[browser] Fix WebAssembly publish output path message - #132829

Merged
maraf merged 2 commits into
dotnet:mainfrom
maraf:maraf-wasm-publish-path-fix
Sep 7, 2026
Merged

maraf merged 2 commits into
dotnet:mainfrom
maraf:maraf-wasm-publish-path-fix

Conversation

@maraf

@maraf maraf commented Aug 27, 2026

Copy link
Copy Markdown
Member

Fixes #99292
Related change in SDK dotnet/sdk#55963

wasmbrowser publish currently reports the generic publish/ directory even though the servable application is under publish/wwwroot/. Add shared WebAssembly build and publish messages that identify the wwwroot output directory, while suppressing nested-publish duplicates.

The Wasm template tests assert the exact build and publish paths and require one occurrence per phase.

Expected console output:

Before:
app -> bin/Release/net8.0/publish/

After:
app -> bin/Release/net8.0/publish/
app (wwwroot) -> bin/Release/net8.0/publish/wwwroot/

The corresponding dotnet/sdk change should remove the obsolete Blazor 6.0 _BlazorCopyFilesToOutputDirectory output message so the shared target is the single source of truth. That change is outside this repository.

Validation: Mono/libraries baselines and browser-wasm package build succeeded. The focused WBT test assembly builds, but test execution is blocked in this environment by the local workload package-version check in eng/testing/workloads-browser.targets.

Note

This pull request description was generated with GitHub Copilot.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@azure-pipelines

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

@maraf maraf changed the title Fix WebAssembly publish output path message [browser] Fix WebAssembly publish output path message Aug 27, 2026
@maraf maraf added arch-wasm WebAssembly architecture os-browser Browser variant of arch-wasm labels Aug 27, 2026
@maraf maraf added this to the 12.0.0 milestone Aug 27, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts WebAssembly browser (wasmbrowser) build/publish logging so console output identifies the servable wwwroot directory (e.g., publish/wwwroot/) rather than only the generic publish/ path, and adds coverage to ensure the message appears exactly once per phase.

Changes:

  • Add high-importance MSBuild messages for $(TargetDir)/wwwroot (build) and $(PublishDir)/wwwroot (publish), suppressed during nested publish.
  • Add a Wasm template test that asserts the new (wwwroot) -> .../wwwroot/ message occurs exactly once in both build and publish output.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs Adds a test asserting the (wwwroot) output-directory messages appear once for build and publish.
src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets Emits new high-importance messages for build/publish wwwroot output directories, skipping nested publish.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>\nCopilot-Session: 8afff773-0b32-46c7-8faa-231ce9df9ff1
@maraf
maraf marked this pull request as ready for review September 3, 2026 10:56
Copilot AI review requested due to automatic review settings September 3, 2026 10:56
@azure-pipelines

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The new test and build-phase message appear to compute/output inconsistent path forms (absolute vs relative), making the assertions and console output behavior likely incorrect/brittle.

Review details

Suppressed comments (3)

Previously missed (2) — in code that hasn't changed since the last review.

src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets:980

  • PublishDir is normalized from the relative $(OutputPath) in this targets file (so the publish message prints a relative bin/.../publish/wwwroot/), but the build message uses $(TargetDir) (typically rooted/full). That risks inconsistent output (absolute for build, relative for publish) and makes the message less likely to match what terminal logging and tests expect. Prefer basing the build message on $(OutputPath) for consistency with the publish path computation here.
    src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs:69
  • The test builds the expected (wwwroot) output directories using projectDir, producing an absolute path. The WebAssembly SDK targets set PublishDir/OutputPath as relative (bin/...) paths, and the console output message is intended to show those relative paths; this assertion is likely to fail by mismatching absolute vs relative.

This issue also appears on line 73 of the same file.

src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs:77

  • Same as build: the publish assertion currently expects an absolute .../bin/.../publish/wwwroot/ path, but PublishDir is defined as a relative bin/.../publish/ path in the imported targets. This makes the test brittle and likely incorrect for the actual console output.
            string publishOutputDirectory = Path.Combine(
                projectDir,
                "bin",
                config.ToString(),
                DefaultTargetFramework,
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@maraf
maraf merged commit 58fee29 into dotnet:main Sep 7, 2026
46 of 47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture area-Build-mono os-browser Browser variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[browser] Wrong directory outputed for publish wasmbrowser template based app

3 participants