Migrate manifest-handling tasks to TaskEnvironment API#13177
Draft
JanProvaznik wants to merge 2 commits intodotnet:mainfrom
Draft
Migrate manifest-handling tasks to TaskEnvironment API#13177JanProvaznik wants to merge 2 commits intodotnet:mainfrom
JanProvaznik wants to merge 2 commits intodotnet:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates manifest-handling MSBuild tasks to support multithreaded execution (-mt mode) by implementing the IMultiThreadableTask interface and using TaskEnvironment for thread-safe file operations.
Changes:
- Added
[MSBuildMultiThreadableTask]attribute andIMultiThreadableTaskinterface to 9 manifest-handling tasks - Replaced
Directory.GetCurrentDirectory()withTaskEnvironment.ProjectDirectoryandPath.GetFullPath()withTaskEnvironment.GetAbsolutePath() - Updated 20 unit test methods to initialize
TaskEnvironmentusingTaskEnvironmentHelper.CreateForTest()
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| UpdateManifest.cs | Added attribute/interface, absolutized paths for both .NET and .NET Framework implementations |
| ResolveManifestFiles.cs | Added attribute/interface, replaced Path.GetFullPath() with TaskEnvironment.GetAbsolutePath() |
| GenerateManifestBase.cs | Base class - added TaskEnvironment, replaced Directory.GetCurrentDirectory(), absolutized manifest paths |
| GenerateApplicationManifest.cs | Absolutized TrustInfoFile and InputManifest paths using TaskEnvironment |
| CreateManifestResourceName.cs | Base class - added attribute/interface, absolutized paths before file operations |
| CreateCSharpManifestResourceName.cs | Added [MSBuildMultiThreadableTask] attribute |
| CreateVisualBasicManifestResourceName.cs | Added [MSBuildMultiThreadableTask] attribute |
| AddToWin32Manifest.cs | Added attribute/interface, absolutized ApplicationManifest and output paths |
| CreateCSharpManifestResourceName_Tests.cs | Updated 13 test methods with TaskEnvironment initialization |
| CreateVisualBasicManifestResourceName_Tests.cs | Updated 6 test methods with TaskEnvironment initialization |
| AddToWin32Manifest_Tests.cs | Updated 1 test method with TaskEnvironment initialization |
23f07ef to
c947264
Compare
Migrate the following tasks to support multithreaded execution (-mt mode): - GenerateManifestBase (base class for manifest generation) - GenerateApplicationManifest - GenerateDeploymentManifest (inherits from GenerateManifestBase) - ResolveManifestFiles - AddToWin32Manifest - UpdateManifest - CreateManifestResourceName (base class for resource naming) - CreateCSharpManifestResourceName - CreateVisualBasicManifestResourceName Changes: - Add [MSBuildMultiThreadableTask] attribute to all tasks - Implement IMultiThreadableTask interface where TaskEnvironment is used - Replace Directory.GetCurrentDirectory() with TaskEnvironment.ProjectDirectory - Absolutize all paths before file I/O operations using TaskEnvironment.GetAbsolutePath() - Update unit tests to set TaskEnvironment = TaskEnvironmentHelper.CreateForTest() Fixes dotnet#13172
c947264 to
e5763fd
Compare
- Fix ResolveManifestFiles to canonicalize paths for dictionary key matching (GetAbsolutePath doesn't canonicalize, so wrap with Path.GetFullPath) - Add 8 focused tests for TaskEnvironment migration: - Empty ItemSpec handling - Path with .. segments (canonicalization) - Forward/mixed slashes normalization - Batch processing error handling - Deep nesting and spaces in paths
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.
Migrate manifest-handling tasks to TaskEnvironment API
Summary
This PR migrates manifest-handling MSBuild tasks to support multithreaded execution (
-mtmode) by implementing theIMultiThreadableTaskinterface and usingTaskEnvironmentfor thread-safe file operations.Fixes #13172
Changes
Tasks Migrated
TaskEnvironment, replacedDirectory.GetCurrentDirectory()withTaskEnvironment.ProjectDirectory, absolutizedInputManifestandOutputManifestpathsTrustInfoFilepath inGetRequestedExecutionLevel()GenerateManifestBase- no additional changes neededPath.GetFullPath()calls withTaskEnvironment.GetAbsolutePath()ApplicationManifestand output pathsTaskEnvironment, absolutized paths beforeFileExistsandFileStreamoperations[MSBuildMultiThreadableTask]attribute[MSBuildMultiThreadableTask]attributeTest Updates
Updated unit tests to initialize
TaskEnvironment:AddToWin32Manifest_Tests.csCreateCSharpManifestResourceName_Tests.cs(13 test methods)CreateVisualBasicManifestResourceName_Tests.cs(6 test methods)Testing
Unit Tests
All 148 manifest-related unit tests pass:
E2E Tests
Created 5 end-to-end test projects validating behavior in
-m -mtmode:E2E test package attached:
manifest-e2e-tests.zipmanifest-e2e-tests.zip
To run:
Implementation Notes
manifest-e2e-tests.zip
Pattern Used
Key Replacements
Directory.GetCurrentDirectory()→TaskEnvironment.ProjectDirectoryPath.GetFullPath(path)→TaskEnvironment.GetAbsolutePath(path)Checklist
[MSBuildMultiThreadableTask]attributeIMultiThreadableTaskwhereTaskEnvironmentis usedDirectory.GetCurrentDirectory()orEnvironment.CurrentDirectoryTaskEnvironment = TaskEnvironmentHelper.CreateForTest()-m -mtmode