Skip to content

Prevent Microsoft.AspNetCore.App.Internal.Assets from packing without framework assets - #68977

Merged
akoeplinger merged 4 commits into
mainfrom
copilot/prevent-empty-assets-packing
Sep 4, 2026
Merged

Prevent Microsoft.AspNetCore.App.Internal.Assets from packing without framework assets#68977
akoeplinger merged 4 commits into
mainfrom
copilot/prevent-empty-assets-packing

Conversation

Copilot AI commented Sep 2, 2026

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. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

Prevent incomplete Microsoft.AspNetCore.App.Internal.Assets packages.

Description

Microsoft.AspNetCore.App.Internal.Assets could successfully produce a NuGet package without its required Blazor framework assets when BuildNodeJS=false. The resulting package restored successfully but caused /_framework/blazor.web.js to return 404 at runtime.

This change ensures that an incomplete package is never emitted:

  • The project is non-packable when BuildNodeJS=false, preserving intentional no-NodeJS and source-build configurations.
  • Package validation runs only when the project remains packable, preserving platform-specific-only CI legs.
  • Pack fails when any expected script or source map is absent.
  • The final NuGet _PackageFiles list is checked for blazor.web.js, blazor.server.js, and both source maps before GenerateNuspec runs.
  • The validation uses NuGet's BeforePack hook so input validation also runs when GenerateNuspec would otherwise be incrementally up-to-date.
  • Existing package-layout coverage now verifies all four files in the produced archive.

Verification

  • BuildNodeJS=false pack succeeds without producing a .nupkg.
  • OnlyPackPlatformSpecificPackages=true pack succeeds without producing this RID-agnostic package.
  • Explicit Build succeeds in both no-NodeJS and platform-specific-only configurations.
  • Removing an expected source map makes pack fail without producing a package.
  • JS-enabled pack produces exactly one package containing all four expected assets.
  • AssetsInternalPackage_ShipsBlazorScriptsAndSourceMaps passes against the built package.

Fixes #68975

… JS assets

Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix packing of Microsoft.AspNetCore.App.Internal.Assets without framework assets Prevent Microsoft.AspNetCore.App.Internal.Assets from packing without framework assets Sep 2, 2026
Copilot AI requested a review from javiercn September 2, 2026 10:58
Fail before NuGet writes Microsoft.AspNetCore.App.Internal.Assets when the JavaScript build is disabled, expected files are absent, or the final package input list omits an asset. Extend package layout coverage to include source maps.

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

Copilot-Session: 9dfccfb4-d58e-4004-b6ff-cd528d1c1601
@javiercn
javiercn marked this pull request as ready for review September 2, 2026 15:58
@javiercn
javiercn requested a review from a team as a code owner September 2, 2026 15:58
Copilot AI lite review requested due to automatic review settings September 2, 2026 15:58
Preserve no-NodeJS and platform-specific-only build configurations by skipping package validation when Microsoft.AspNetCore.App.Internal.Assets is not packable.

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

Copilot-Session: 9dfccfb4-d58e-4004-b6ff-cd528d1c1601

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.

🟢 Approval recommended

The changes directly enforce package integrity in the failing configuration and add corresponding automated package-layout coverage for the expected shipped assets.

Pull request overview

Prevents producing an incomplete Microsoft.AspNetCore.App.Internal.Assets NuGet package (notably when BuildNodeJS=false) by making the project non-packable in that configuration and adding pack-time validation to ensure required Blazor framework JS assets and source maps are present before packaging.

Changes:

  • Marks Microsoft.AspNetCore.App.Internal.Assets as non-packable when BuildNodeJS=false and adds BeforePack/GenerateNuspec-time validation targets to fail packing if required assets are missing.
  • Refactors asset item definitions to centralize the expected Blazor framework files in a single item list used by both packaging and validation.
  • Extends package-layout tests to verify both .js files and their .map files are present in the produced package.
File summaries
File Description
src/Assets/Microsoft.AspNetCore.App.Internal.Assets.csproj Disables packing when NodeJS build is off and adds pack input/output validation to prevent emitting incomplete internal-assets packages.
src/Components/WebView/test/StaticWebAssets/PackageLayoutTests.cs Updates packaging assertions to require the two Blazor scripts and their source maps in the internal-assets package.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@Youssef1313 Youssef1313 added the area-blazor Includes: Blazor, Razor Components label Sep 2, 2026
@akoeplinger
akoeplinger merged commit 27a4d6a into main Sep 4, 2026
38 checks passed
@akoeplinger
akoeplinger deleted the copilot/prevent-empty-assets-packing branch September 4, 2026 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-blazor Includes: Blazor, Razor Components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prevent Microsoft.AspNetCore.App.Internal.Assets from packing without framework assets

6 participants