Migrate DefineStaticWebAssets to multithreaded task execution#55117
Open
AlesProkop wants to merge 1 commit into
Open
Migrate DefineStaticWebAssets to multithreaded task execution#55117AlesProkop wants to merge 1 commit into
AlesProkop wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates DefineStaticWebAssets to MSBuild multithreaded task execution by routing all path resolution through TaskEnvironment.ProjectDirectory (instead of process CWD) and updating related Static Web Assets normalization + cache invalidation behavior.
Changes:
- Marked
DefineStaticWebAssetsas[MSBuildMultiThreadableTask]and addedIMultiThreadableTask/TaskEnvironmentplumbing for MT-safe path resolution. - Updated Static Web Asset normalization/file resolution APIs to accept a
TaskEnvironmentso relative paths resolve against the project directory. - Reworked cache manifest path absolutization and cache input hashing to avoid CWD-sensitive metadata, adding MT-focused test coverage.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test/Microsoft.NET.Sdk.StaticWebAssets.Tests/StaticWebAssets/DefineStaticWebAssetsMultiThreadingTest.cs | Adds tests validating MT-safe resolution against TaskEnvironment.ProjectDirectory and cache invalidation under a decoy process CWD. |
| src/StaticWebAssetsSdk/Tasks/DefineStaticWebAssets.cs | Switches candidate identity/content-root handling to use TaskEnvironment and MT-safe file resolution. |
| src/StaticWebAssetsSdk/Tasks/DefineStaticWebAssets.Cache.cs | Absolutizes cache manifest path via TaskEnvironment and updates cache input hashing to be MT/CWD independent. |
| src/StaticWebAssetsSdk/Tasks/Data/StaticWebAsset.cs | Extends asset construction/normalization to accept TaskEnvironment (fallback preserved for existing callers). |
Comment on lines
+20
to
24
| var cacheManifestPath = string.IsNullOrEmpty(CacheManifestPath) | ||
| ? CacheManifestPath | ||
| : TaskEnvironment.GetAbsolutePath(CacheManifestPath).Value; | ||
| var assetsCache = DefineStaticWebAssetsCache.ReadOrCreateCache(Log, cacheManifestPath); | ||
| if (CacheManifestPath == null) |
| } | ||
|
|
||
| [TestMethod] | ||
| public void CacheInvalidatesRelativeCandidateWhenProjectFileChanges_NotProcessCurrentDirectory() |
OvesN
reviewed
Jul 3, 2026
| if (Path.IsPathRooted(candidateMatchPath) && candidateMatchPath == candidate.ItemSpec) | ||
| { | ||
| var normalizedAssetPath = Path.GetFullPath(candidate.GetMetadata("FullPath")); | ||
| var normalizedAssetPath = Path.GetFullPath(TaskEnvironment.GetAbsolutePath(candidate.ItemSpec)); |
Contributor
There was a problem hiding this comment.
Will it not be the same as candidate.GetMetadata("FullPath") ?
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#14040
Context
DefineStaticWebAssetsnow participates in MSBuild multithreaded task execution. Relative candidate paths, content roots, cache manifest paths, and cache input keys must resolve againstTaskEnvironment.ProjectDirectoryinstead of the process current directory.Changes Made
[MSBuildMultiThreadableTask],IMultiThreadableTask, andTaskEnvironmentsupport toDefineStaticWebAssets.TaskEnvironmentthroughStaticWebAsset.FromProperties, normalization, file resolution, and related content-root handling.CacheManifestPathrelative toTaskEnvironment.ProjectDirectory.DefineStaticWebAssetscache input hashing to avoid CWD-sensitiveFullPathandModifiedTimemetadata, hashing MT-safe candidate paths and file state instead.DefineStaticWebAssetsMultiThreadingTestcoverage for relative candidate/content-root resolution and cache invalidation under a decoy process CWD.Testing
dotnet build src/StaticWebAssetsSdk/Tasks/Microsoft.NET.Sdk.StaticWebAssets.Tasks.csproj— passed fornet11.0andnet472.dotnet test test/Microsoft.NET.Sdk.StaticWebAssets.Tests/Microsoft.NET.Sdk.StaticWebAssets.Tests.csproj --filter "FullyQualifiedName~DefineStaticWebAssetsMultiThreadingTest"— passed, 2 tests.