Repository navigation
Migrate ConcatenateCssFiles - #55002
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Migrates the ConcatenateCssFiles Static Web Assets MSBuild task to MSBuild’s multi-threaded task execution model by introducing TaskEnvironment-rooted path resolution, and adds a regression test to ensure behavior is independent of the process current working directory.
Changes:
- Marked
ConcatenateCssFilesas[MSBuildMultiThreadableTask], implementedIMultiThreadableTask, and introduced aTaskEnvironmentproperty. - Updated input and output file IO to resolve paths via
TaskEnvironment.GetAbsolutePath(...)rather than relying on process CWD. - Added a multi-threading regression test validating input reads and output writes are rooted in
TaskEnvironment.ProjectDirectory.
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/ConcatenateCssFilesMultiThreadingTest.cs | Adds a regression test to verify bundling behavior is independent of the process current directory. |
| src/StaticWebAssetsSdk/Tasks/ScopedCss/ConcatenateCssFiles.cs | Makes the task multi-threadable and updates IO to use TaskEnvironment for path resolution. |
Comments suppressed due to low confidence (1)
src/StaticWebAssetsSdk/Tasks/ScopedCss/ConcatenateCssFiles.cs:18
- The task still sorts
ScopedCssFiles/ProjectBundlesusingGetMetadata("FullPath"). In this task invocation,FullPathisn’t materialized by MSBuild (items are passed without%(FullPath)), soTaskItem.GetMetadata("FullPath")will be computed at task runtime and can still be rooted in the process current directory. That undermines the MT-host migration goal and can make bundle ordering depend on CWD. Consider sorting byItemSpec(or by aTaskEnvironment-rooted absolute path) instead ofFullPath.
public class ConcatenateCssFiles : Task, IMultiThreadableTask
{
private static readonly char[] _separator = ['/'];
private static readonly IComparer<ITaskItem> _fullPathComparer =
…ebAssets.Tests MSTest.Sdk migration
OvesN
requested changes
Jun 30, 2026
OvesN
approved these changes
Jun 30, 2026
jankratochvilcz
approved these changes
Jul 1, 2026
AlesProkop
enabled auto-merge (squash)
July 1, 2026 07:12
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#14169
Context
Migrates the
ConcatenateCssFilesMSBuild task to the multithreaded execution model. The task reads scoped-css inputs and writes the bundle to disk, so it must resolve every path against the task's own project directory viaTaskEnvironmentinstead of relying on the process-global current directory that the shared multithreaded host no longer guarantees.Changes Made
[MSBuildMultiThreadableTask]and implementedIMultiThreadableTaskonConcatenateCssFiles.TaskEnvironmentproperty defaulting toTaskEnvironment.Fallback.File.ReadLines(current.GetMetadata("FullPath"))is nowFile.ReadLines(TaskEnvironment.GetAbsolutePath(current.ItemSpec)).outputFile = TaskEnvironment.GetAbsolutePath(OutputFile)and routedFile.Exists,SameContent,Directory.CreateDirectory, andFile.WriteAllTextthrough it.Testing
Microsoft.NET.Sdk.StaticWebAssets.Tasks.csproj(net11.0 and net472) with the dotnet/msbuildMicrosoft.Build.TaskAuthoring.Analyzertemporarily injected;ConcatenateCssFiles.cscompiles and the analyzer surfaces only oneMSBuildTask0003(theSameContentread — a false positive, see Notes).ConcatenateCssFilesMultiThreadingTestinMicrosoft.NET.Sdk.StaticWebAssets.Tests:ReadsInputsAndWritesBundleRelativeToTaskEnvironmentProjectDirectory_NotProcessCurrentDirectory