Skip to content

Fix StaticWebAssets FUTDC not tracking referenced project changes#53426

Draft
oroztocil wants to merge 3 commits intomainfrom
oroztocil/staticwebassets-futdc
Draft

Fix StaticWebAssets FUTDC not tracking referenced project changes#53426
oroztocil wants to merge 3 commits intomainfrom
oroztocil/staticwebassets-futdc

Conversation

@oroztocil
Copy link
Member

@oroztocil oroztocil commented Mar 12, 2026

Problem

When a Blazor Web App with WebAssembly + Global interactivity has a .razor.css file modified in the Client project, the Server project's build is skipped by VS's Fast Up-to-Date Check (FUTDC). The Server's .staticwebassets.endpoints.json manifest retains stale fingerprints and ETags, causing the app to fail at runtime with "An unhandled error has occurred."

Fixes #53425
Fixes dotnet/aspnetcore#65738

Investigation

See #53425 for the analysis of the problem.

Change

Microsoft.NET.Sdk.StaticWebAssets.Design.targets

Added ResolveReferencedProjectsStaticWebAssetsConfiguration to CollectUpToDateCheckInputDesignTimeDependsOn. This ensures the references file is written during design-time evaluation, before CollectStaticWebAssetInputsDesignTime tries to read it.

Microsoft.NET.Sdk.StaticWebAssets.References.targets

Changed Overwrite="false" to Overwrite="true" on the WriteLinesToFile call. The file is fully populated from @(_ReferenceManifestPath) on each build, so there is no need to append. The existing WriteOnlyWhenDifferent="true" attribute ensures the file timestamp only changes when the content actually differs, preserving correct FUTDC behavior.

Risk

ResolveReferencedProjectsStaticWebAssetsConfiguration calls GetStaticWebAssetsProjectConfiguration on referenced projects, which is a metadata-only call (it does not resolve actual assets). The expensive ResolveReferencedProjectsStaticWebAssets target is not added to the design-time chain.

Copilot AI review requested due to automatic review settings March 12, 2026 22:24
@github-actions github-actions bot added the Area-AspNetCore RazorSDK, BlazorWebAssemblySDK, StaticWebAssetsSDK label Mar 12, 2026
@dotnet-policy-service
Copy link
Contributor

Thanks for your PR, @@oroztocil.
To learn about the PR process and branching schedule of this repo, please take a look at the SDK PR Guide.

Copy link
Contributor

Copilot AI left a comment

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 Visual Studio Fast Up-to-Date Check (FUTDC) design-time timing issue in Static Web Assets for Blazor solutions with referenced projects, ensuring referenced-project changes (e.g., scoped CSS outputs) are correctly tracked so stale endpoint manifests aren’t reused at runtime.

Changes:

  • Adds ResolveReferencedProjectsStaticWebAssetsConfiguration to the design-time FUTDC input dependency chain so the referenced-projects UTDC manifest file is generated before it is read.

$(CollectUpToDateCheckInputDesignTimeDependsOn);
ResolveStaticWebAssetsConfiguration;
ResolveProjectStaticWebAssets;
ResolveReferencedProjectsStaticWebAssetsConfiguration;
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

Adding ResolveReferencedProjectsStaticWebAssetsConfiguration to the design-time FUTDC input chain means this target will now run frequently during design-time builds. That target currently writes $(StaticWebAssetReferencesUpToDateCheckManifestPath) using WriteLinesToFile with Overwrite="false" (append) in Microsoft.NET.Sdk.StaticWebAssets.References.targets, which can cause the manifest file to grow with duplicate/stale entries across repeated evaluations and potentially degrade FUTDC performance. Consider adjusting the referenced target to overwrite (or otherwise de-dupe) the file when it is generated during design-time evaluation so the tracked inputs remain bounded and accurate.

Suggested change
ResolveReferencedProjectsStaticWebAssetsConfiguration;

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted to have this change as a separate PR (as it is an independent problem, only made more noticeable by the primary fix here). However, added it to this PR.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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

oroztocil and others added 3 commits March 13, 2026 01:05
The design-time target CollectStaticWebAssetInputsDesignTime reads
referenced project build manifest paths from
staticwebassets.references.upToDateCheck.txt. However, this file is
written by the build-time target
ResolveReferencedProjectsStaticWebAssetsConfiguration, which has not
run yet when VS evaluates the design-time dependency chain on initial
project load. The file does not exist, the read is skipped, and VS CPS
caches the empty result. Subsequent builds create the file but the
design-time cache is never invalidated.

This causes the Server project's FUTDC to miss changes in referenced
projects' static web assets (e.g. scoped CSS bundles), skipping the
Server rebuild and leaving stale fingerprints in the endpoints manifest.

Fix by adding ResolveReferencedProjectsStaticWebAssetsConfiguration to
CollectUpToDateCheckInputDesignTimeDependsOn so the references file is
written during design-time evaluation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
WriteLinesToFile in ResolveReferencedProjectsStaticWebAssetsConfiguration
uses Overwrite=false, which appends referenced project manifest paths on
every build instead of replacing the file contents. This causes the file
to grow indefinitely with duplicate entries.

Change to Overwrite=true. The WriteOnlyWhenDifferent=true attribute is
already set, so the file timestamp will only change when the content
actually differs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add a regression test that exercises the
design-time FUTDC input collection on a clean obj folder (no prior
build). This covers the scenario where VS evaluates FUTDC inputs on
initial project load before any build has occurred.

The existing test CollectUpToDateCheckInputOutputsDesignTime_IncludesReferencedProjectsManifests
runs a full build first, so staticwebassets.references.upToDateCheck.txt
already exists when the design-time targets read it.

The new test skips the prior build and invokes the design-time targets
directly, asserting that referenced project manifest paths are still
included in UpToDateCheckInput. This would fail without the fix in
Design.targets that adds ResolveReferencedProjectsStaticWebAssetsConfiguration
to the design-time dependency chain.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@oroztocil oroztocil force-pushed the oroztocil/staticwebassets-futdc branch from 673b001 to 1e478f0 Compare March 13, 2026 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-AspNetCore RazorSDK, BlazorWebAssemblySDK, StaticWebAssetsSDK

Projects

None yet

2 participants