Skip to content

Do not publish precompressed RCL assets from Blazor Hybrid apps - #70634

Open
joshbarros wants to merge 1 commit into
dotnet:mainfrom
joshbarros:fix/70394-hybrid-publish-precompressed
Open

joshbarros wants to merge 1 commit into
dotnet:mainfrom
joshbarros:fix/70394-hybrid-publish-precompressed

Conversation

@joshbarros

Copy link
Copy Markdown
Contributor
  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making.

Description

Blazor Hybrid sets CompressionEnabled=false in this package's targets, but referenced RCLs still contribute precompressed .gz/.br copies of their assets as AssetRole="Alternative" static web assets. Those items reach the publish pipeline and are copied next to the uncompressed assets under publish/wwwroot/_content/<Rcl>/.

Remove Alternative .gz/.br assets from @(StaticWebAsset) before the publish manifest, the publish asset resolution and the Brotli publish pass, but only while CompressionEnabled is false. The assets are not used by WebViewManager, which serves the uncompressed files without HTTP content-encoding negotiation.

Validation

This is an MSBuild target change. I could not run a MAUI/WPF Hybrid publish in this environment; CI will exercise the template builds. The condition is limited to CompressionEnabled=false, which is set for all Blazor Hybrid consumers.

Fixes #70394

@joshbarros
joshbarros requested a review from a team as a code owner November 16, 2026 20:15
@github-actions github-actions Bot added the area-blazor Includes: Blazor, Razor Components label Nov 16, 2026
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Nov 16, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Thanks for your PR, @joshbarros. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@PureWeen

Copy link
Copy Markdown
Member

/review

@github-actions github-actions Bot 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.

Source-only review of frozen head 1541c07cd0cdaca24092e46dd6f06a454e5fe8e4.

One unresolved P2 candidate is attached inline: the new target removes precompressed StaticWebAsset items without explicitly removing corresponding endpoint items. The frozen ASP.NET Core source establishes the changed edge and publish trigger, but the external Microsoft.NET.Sdk.StaticWebAssets implementation required to prove endpoint reconciliation is not in the bundle, so this is not presented as a verified defect.

Per-guide completion:

  • docs/CrossCuttingGuidance.md: complete; change shape, compatibility, MSBuild condition/metadata, packaging, cross-platform behavior, and source-level test coverage assessed.
  • docs/BlazorComponentsGuidance.md: complete; packaging scope, target ordering, filtering, consumer impact, comments, and source-level test boundary assessed.

Existing-feedback coverage: none; the frozen feedback contains only the policy bot acknowledgement and /review invocation. Feedback posted after bundle preparation was not observable.

Uncovered areas: none materially changed outside the routed cross-cutting and Blazor Components guides. Security assessment and execution of builds, publishes, tests, CI, browser workflows, and samples were explicitly excluded.

Provenance: version-2 frozen bundle for PR #70634; head 1541c07cd0cdaca24092e46dd6f06a454e5fe8e4, merge base 59835e6087e90b972a905dc303523cfbb5d828ef, base tip and trusted guidance commit 18781e9d03cba0f3df9cdf7fae90f77771ca9f00. Proof is source-only. No target code was executed.

Limitations: tracked Git bytes only; symlinks, submodules, and LFS pointers are inert. Runtime MSBuild behavior and the external SDK task implementation were unavailable, and no changed regression test covers this publish-output scenario.

Generated by ASP.NET Core Pull Request Review for #70634 · copilot · gpt56 · 159.3 AIC · ⌖ 8.57 AIC · ⊞ 20.1K
Comment /review to run again

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.

🟡 Changes recommended

Existing publish tests cover only the JS module manifest, leaving compressed-asset filtering across normal and --no-build publishes without regression coverage for exclusions, retained originals, and required controls.

1 open issue
What changed in this PR

This PR addresses #70394 by filtering precompressed Razor Class Library assets from the Blazor Hybrid publish pipeline, where WebView serves uncompressed files.

Changes:

  • Adds a target to remove Alternative .gz and .br static web assets when CompressionEnabled=false.
  • Hooks the filter before publish manifest generation, asset resolution, and Brotli compression, while preserving Primary assets.
File Description
src/​Components/​WebView/​WebView/​src/​StaticWebAssets.Groups.targets Adds conditional filtering of precompressed assets before publish processing.

Review effort: Balanced

@PureWeen

Copy link
Copy Markdown
Member

The G/S/O local panel completed review of commit 1541c07cd0cdaca24092e46dd6f06a454e5fe8e4 with no new, non-duplicate verified findings or intent questions. This is not an approval: the existing CCR regression-test request is still unresolved at this commit, so agent-reviewed-needs-changes applies. No duplicate inline comments are being added.

Informational discarded checks: The Alternative-role predicate preserves ordinary Primary .gz/.br items, and the unchanged WebView file-provider path does not depend on compressed endpoint selection. A hook-timing/completeness problem was not observed in O's scoped project-reference reproduction. These are not new change requests. The source bundle also lacked the linked issue's discussion/team acknowledgement; no process violation is alleged.

Posted for informational purposes so the author can confirm the verifier didn't discard or leave unresolved a real finding; this item does not block agent-reviewed-approved. No candidate verifier was invoked because no new provisional finding remained in any arm.

Untested coverage: The packed WebView/NuGet-packaged RCL path and CompressionEnabled=true control were not exercised. The missing permanent regression coverage is already covered by the linked CCR thread.

Validation boundary: G/S were frozen-source-only; O ran base/head normal and --no-build SDK publishes against a P2P RCL with imported target-file copies (all exited 0), not the packed WebView package or repository test suite.

Human-directed and GitHub Copilot-generated.

still reach the publish pipeline and are copied next to the uncompressed files.
Drop them before the publish manifest and the Brotli publish pass run. -->
<Target Name="_RemoveBlazorWebViewPrecompressedAssets"
BeforeTargets="GenerateStaticWebAssetsPublishManifest;ResolvePublishStaticWebAssets;GeneratePublishCompressedStaticWebAssets"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could this filtering be implemented in the shared StaticWebAssets SDK instead of only the WebView targets? With the .NET 11 SDK, a Blazor WebAssembly app with a project-referenced RCL still imports the RCL's compressed alternatives when CompressionEnabled=false; publish then contains gzip and Brotli copies. In my NuGet RCL sample, the package contained uncompressed assets and the consuming app owned compression, so it was already clean. This target addresses the Hybrid publish case but leaves the project-reference leak in other StaticWebAssets scenarios.

The shared SDK already has build and publish resolution hooks in Microsoft.NET.Sdk.StaticWebAssets.targets (publish hook). We could filter Alternative assets with the Content-Encoding trait, which the compression task assigns, and remove their endpoints using the existing filtering pattern. Build and publish need separate target names because publish runs build in the same MSBuild session. A prototype at these hooks removed the project-reference alternatives and published compressed files in the tested sample, while leaving compression-enabled output unchanged.

Note

This comment was generated with the assistance of GitHub Copilot.

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — 1541c07c Deployed Nov 24, 2026 by dotnet-policy-service[bot] via pat_pool #2605
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-reviewed-needs-changes area-blazor Includes: Blazor, Razor Components community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Blazor Hybrid Windows publish still copies precompressed .gz and .br assets from referenced RCLs into publish/wwwroot

4 participants