Skip to content

Avoid duplicate TypeScript static web assets - #55951

Merged
javiercn merged 1 commit into
mainfrom
javiercn-fix-typescript-asset-cleanup
Aug 27, 2026
Merged

javiercn merged 1 commit into
mainfrom
javiercn-fix-typescript-asset-cleanup

Conversation

@javiercn

Copy link
Copy Markdown
Member

Summary

  • replace TypeScript outputs that were already discovered as static web assets before compilation
  • remove their stale endpoints before registering the freshly generated outputs
  • add regression coverage for retained generated outputs after bin and obj cleanup

Fixes #55945

Replace static web assets and endpoints discovered before TypeScript compilation with registrations based on the generated outputs. Add coverage for retained outputs after bin and obj cleanup.

Fixes #55945

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

Copilot-Session: 6d05048a-04d1-4b67-b0cf-2d6f350a0a69
Copilot AI lite review requested due to automatic review settings August 26, 2026 17:22
@javiercn
javiercn requested a review from a team as a code owner August 26, 2026 17:22
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
2 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.

Pull request overview

This PR fixes a Static Web Assets (SWA) correctness issue where TypeScript-generated outputs under wwwroot could be registered twice (once via @(Content) discovery before compilation, and again via TypeScript registration after compilation), causing downstream SWA tasks (notably compression discovery) to fail due to duplicate asset identities. It implements the “replace stale asset + endpoint entries before re-registering” approach described in the linked issue and adds an integration regression test for the obj/bin-deleted-but-outputs-retained scenario.

Changes:

  • In RegisterTypeScriptStaticWebAssets, remove any already-registered @(StaticWebAsset) items that match TypeScript output full paths before re-defining them post-compilation.
  • Remove any @(StaticWebAssetEndpoint) entries associated with those stale assets before defining endpoints for the freshly generated TypeScript assets.
  • Add an integration test that builds, deletes obj/bin while retaining wwwroot outputs, then rebuilds with compression enabled and asserts single asset/endpoint registration.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/StaticWebAssetsSdk/Targets/Microsoft.NET.Sdk.StaticWebAssets.TypeScript.targets Removes stale SWA asset + endpoint entries for TypeScript outputs (by physical identity) before re-registering with post-compilation metadata.
test/Microsoft.NET.Sdk.StaticWebAssets.Tests/TypeScriptIntegrationTest.cs Adds regression coverage for rebuilding after obj/bin cleanup while TypeScript outputs remain under wwwroot.

@javiercn
javiercn enabled auto-merge (squash) August 27, 2026 13:50
@javiercn
javiercn merged commit da0e0f0 into main Aug 27, 2026
23 checks passed
@javiercn
javiercn deleted the javiercn-fix-typescript-asset-cleanup branch August 27, 2026 17:30
@SamMonoRT

Copy link
Copy Markdown
Member

@javiercn - this can be backported for 11/RC2

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/11.0-rc2 (link to workflow run)

@javiercn

Copy link
Copy Markdown
Member Author

/backport to release/11.0.1xx-rc2

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/11.0.1xx-rc2 (link to workflow run)

@github-actions

Copy link
Copy Markdown
Contributor

@javiercn an error occurred while backporting to release/11.0-rc2. See the workflow output for details.

@github-actions

Copy link
Copy Markdown
Contributor

@javiercn an error occurred while backporting to release/11.0.1xx-rc2. See the workflow output for details.

@javiercn

Copy link
Copy Markdown
Member Author

/backport to release/11.0.1xx-rc1

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/11.0.1xx-rc1 (link to workflow run)

@javiercn

Copy link
Copy Markdown
Member Author

/backport to release/11.0.1xx

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/11.0.1xx (link to workflow run)

This branch had an error being deployed

1 failed deployment
copilot-pat-pool — 6b704ebc Deployed Aug 27, 2026 by javiercn via pre_activation #1308
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeScript static web asset registration duplicates retained generated outputs after obj cleanup

4 participants