Skip to content

Migrate ResolveFingerprintedStaticWebAssetEndpointsForAssets - #54997

Merged
AlesProkop merged 4 commits into
dotnet:mainfrom
AlesProkop:migrate-resolve-finger-printed-static-web-asset-endpoints-for-assets
Jul 1, 2026
Merged

AlesProkop merged 4 commits into
dotnet:mainfrom
AlesProkop:migrate-resolve-finger-printed-static-web-asset-endpoints-for-assets

Conversation

@AlesProkop

@AlesProkop AlesProkop commented Jun 26, 2026 •

Copy link
Copy Markdown
Member

Fixes dotnet/msbuild#14167

Context

Migrates the ResolveFingerprintedStaticWebAssetEndpointsForAssets task to MSBuild's multithreaded execution model so asset path normalization roots relative paths against the task's project directory instead of the process current directory.

Changes Made

  • Annotated ResolveFingerprintedStaticWebAssetEndpointsForAssets with [MSBuildMultiThreadableTask] and implemented IMultiThreadableTask.
  • Added a TaskEnvironment property initialized to TaskEnvironment.Fallback.
  • Forwarded TaskEnvironment into StaticWebAsset.FromTaskItemGroup(CandidateAssets, TaskEnvironment) in Execute() so asset normalization uses the project directory.

Testing

  • Built Microsoft.NET.Sdk.StaticWebAssets.Tasks and Microsoft.NET.Sdk.StaticWebAssets.Tests — 0 warnings, 0 errors.
  • Added and ran focused tests in ResolveFingerprintedStaticWebAssetEndpointsForAssetsTest:
    • ResolvesEndpoints_WhenTaskEnvironmentProjectDirectoryDiffersFromProcessCurrentDirectory — sets the process CWD to a decoy directory, points TaskEnvironment at a separate project directory, feeds a candidate with a relative ContentRoot, and asserts the task completes with no errors and resolves the fingerprinted route candidate.asdf1234.js.
    • Result: 8 passed, 0 failed (1 new + 7 existing in the class).
  • Ran the dotnet/msbuild Microsoft.Build.TaskAuthoring.Analyzer against the task project: the only diagnostic on this task is one MSBuildTask0005 for Path.GetFullPath reached via StaticWebAsset.Normalize, which is a false positive (it canonicalizes an already-absolute AbsolutePath from env.GetAbsolutePath(...)).

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

Migrates ResolveFingerprintedStaticWebAssetEndpointsForAssets to MSBuild’s multithreaded task model by implementing IMultiThreadableTask and ensuring static web asset normalization uses the task’s TaskEnvironment (project directory) instead of the process current directory.

Changes:

  • Marked ResolveFingerprintedStaticWebAssetEndpointsForAssets as [MSBuildMultiThreadableTask] and implemented IMultiThreadableTask with a TaskEnvironment property.
  • Forwarded TaskEnvironment into StaticWebAsset.FromTaskItemGroup(...) during task execution.
  • Added a new unit test intended to validate behavior when process CWD differs from the project directory.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/StaticWebAssetsSdk/Tasks/ResolveFingerprintedStaticWebAssetEndpointsForAssets.cs Implements MSBuild multi-threading contract and uses TaskEnvironment when parsing candidate assets.
test/Microsoft.NET.Sdk.StaticWebAssets.Tests/StaticWebAssets/ResolveFingerprintedStaticWebAssetEndpointsForAssetsTest.cs Adds coverage for differing process CWD vs. project directory during endpoint resolution.

@jankratochvilcz jankratochvilcz 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.

Please see comment about test coverage, rest looks a-good!

@OvesN OvesN 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.

Migration looks fine. Only one thing: the current test "ResolvesEndpoints_WhenTaskEnvironmentProjectDirectoryDiffersFromProcessCurrentDirectory" does not test really test your migration, I think we can safely delete it

@AlesProkop
AlesProkop enabled auto-merge (squash) June 30, 2026 10:49
@AlesProkop
AlesProkop merged commit a7b1326 into dotnet:main Jul 1, 2026
28 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jul 6, 2026
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.

[Multithreaded] Migrate ResolveFingerprintedStaticWebAssetEndpointsForAssets in SDK

4 participants