Repository navigation
Migrate ResolveFingerprintedStaticWebAssetEndpointsForAssets - #54997
Conversation
There was a problem hiding this comment.
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
ResolveFingerprintedStaticWebAssetEndpointsForAssetsas[MSBuildMultiThreadableTask]and implementedIMultiThreadableTaskwith aTaskEnvironmentproperty. - Forwarded
TaskEnvironmentintoStaticWebAsset.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. |
…finger-printed-static-web-asset-endpoints-for-assets
jankratochvilcz
left a comment
There was a problem hiding this comment.
Please see comment about test coverage, rest looks a-good!
OvesN
left a comment
There was a problem hiding this comment.
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
Fixes dotnet/msbuild#14167
Context
Migrates the
ResolveFingerprintedStaticWebAssetEndpointsForAssetstask 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
ResolveFingerprintedStaticWebAssetEndpointsForAssetswith[MSBuildMultiThreadableTask]and implementedIMultiThreadableTask.TaskEnvironmentproperty initialized toTaskEnvironment.Fallback.TaskEnvironmentintoStaticWebAsset.FromTaskItemGroup(CandidateAssets, TaskEnvironment)inExecute()so asset normalization uses the project directory.Testing
Microsoft.NET.Sdk.StaticWebAssets.TasksandMicrosoft.NET.Sdk.StaticWebAssets.Tests— 0 warnings, 0 errors.ResolveFingerprintedStaticWebAssetEndpointsForAssetsTest:ResolvesEndpoints_WhenTaskEnvironmentProjectDirectoryDiffersFromProcessCurrentDirectory— sets the process CWD to a decoy directory, pointsTaskEnvironmentat a separate project directory, feeds a candidate with a relativeContentRoot, and asserts the task completes with no errors and resolves the fingerprinted routecandidate.asdf1234.js.Microsoft.Build.TaskAuthoring.Analyzeragainst the task project: the only diagnostic on this task is oneMSBuildTask0005forPath.GetFullPathreached viaStaticWebAsset.Normalize, which is a false positive (it canonicalizes an already-absoluteAbsolutePathfromenv.GetAbsolutePath(...)).