Repository navigation
migrate FilterStaticWebAssetEndpoints - #54977
Merged
AlesProkop merged 3 commits intoJun 30, 2026
Merged
AlesProkop merged 3 commits into
AlesProkop merged 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Migrates FilterStaticWebAssetEndpoints to be safe under MSBuild’s multithreaded execution by resolving path-bearing Static Web Asset metadata (e.g., ContentRoot) against TaskEnvironment.ProjectDirectory instead of the process current working directory.
Changes:
- Marked
FilterStaticWebAssetEndpointsas[MSBuildMultiThreadableTask]and implementedIMultiThreadableTask, adding aTaskEnvironmentproperty defaulting toTaskEnvironment.Fallback. - Routed asset item-group materialization through
StaticWebAsset.ToAssetDictionary(Assets, TaskEnvironment)soContentRoot/RelatedAssetnormalization uses the per-task environment. - Added a regression test that mutates process CWD and asserts relative
ContentRootresolves againstTaskEnvironment.ProjectDirectory(with assembly-wide xUnit parallelization disabled already in this test project).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/Microsoft.NET.Sdk.StaticWebAssets.Tests/StaticWebAssets/FilterStaticWebAssetEndpointsMultiThreadingTest.cs | Adds a regression test ensuring relative ContentRoot is absolutized using TaskEnvironment.ProjectDirectory rather than process CWD. |
| src/StaticWebAssetsSdk/Tasks/FilterStaticWebAssetEndpoints.cs | Makes the task explicitly multi-threadable and threads TaskEnvironment into asset dictionary construction. |
…tatic-web-asset-endpoints
…er StaticWebAssets.Tests MSTest.Sdk migration
OvesN
approved these changes
Jun 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes dotnet/msbuild#14165
Context
MSBuild's multithreaded execution model requires tasks to avoid process-global state (current working directory).
FilterStaticWebAssetEndpointsabsolutized assetContentRoot/RelatedAssetpaths against the process current directory, so it would resolve them incorrectly when run on a worker thread. This migrates the task to resolve paths against its per-instanceTaskEnvironment.ProjectDirectory.Changes Made
FilterStaticWebAssetEndpointswith[MSBuildMultiThreadableTask]and implementedIMultiThreadableTask.TaskEnvironmentproperty defaulting toTaskEnvironment.Fallbackto preserve single-process semantics.TaskEnvironmentintoStaticWebAsset.ToAssetDictionary(Assets, TaskEnvironment), routingContentRoot/RelatedAssetabsolutization throughenv.GetAbsolutePathinstead of the process current directory.Path.GetFullPathcanonicalization wrapper inNormalizeContentRootPathintact, so dictionary keys and output paths stay canonical.Testing
Microsoft.NET.Sdk.StaticWebAssets.Tests— 0 warnings, 0 errors.FilterStaticWebAssetEndpointsMultiThreadingTest:ResolvesRelativeContentRootAgainstTaskEnvironmentProjectDirectoryNotProcessCurrentDirectory— sets the process CWD to a decoy directory andTaskEnvironment.ProjectDirectoryto a different directory, then asserts the resultingAssetsWithoutMatchingEndpoints[0]ContentRootis rooted to the project directory, not the decoy CWD. The test fails if the migration is reverted.