Repository navigation
Avoid duplicate TypeScript static web assets - #55951
Conversation
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
|
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. |
There was a problem hiding this comment.
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/binwhile retainingwwwrootoutputs, 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 - this can be backported for 11/RC2 |
|
Started backporting to |
|
/backport to release/11.0.1xx-rc2 |
|
Started backporting to |
|
@javiercn an error occurred while backporting to |
|
@javiercn an error occurred while backporting to |
|
/backport to release/11.0.1xx-rc1 |
|
Started backporting to |
|
/backport to release/11.0.1xx |
|
Started backporting to |
Summary
binandobjcleanupFixes #55945