Migrate SGen task to Task environment API#13457
Conversation
…https://github.com/OvesN/msbuild into dev/veronikao/migrate-Al-task-to-TaskEnvironment-API
The test relied on FileAttributes.ReadOnly to force File.Delete to throw, but this is not cross-platform - Unix read-only attributes don't prevent deletion.
ApplyEnvironmentOverrides moved inside SetUpProcessStartInfo. Added override for DeleteTempFile using AbsolutePath. Made Driver private again, expose only enum value to decided if driver is multitheaded. Made GetProcessStartInfoMultithreadable private. add overload for DeleteTempFile with AbsolutePath argument
…nto dev/veronikao/migrate-SGen-Task-to-TaskEnvironment-API
… of https://github.com/OvesN/msbuild into dev/veronikao/migrate-SGen-Task-to-TaskEnvironment-API
There was a problem hiding this comment.
Pull request overview
Migrates the SGen task to the TaskEnvironment API to support thread-safe/multithreaded execution by routing path resolution, file existence checks, and environment variable access through the task environment.
Changes:
- Marked
SGenas multithreadable and updated it to useTaskEnvironment.GetAbsolutePath()/GetEnvironmentVariable(). - Switched several internal path computations to use
AbsolutePath. - Added unit tests covering
TaskEnvironmentintegration for tool path resolution, working directory propagation, andBuildAssemblyPathabsolutization.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
src/Tasks/SGen.cs |
Uses TaskEnvironment for env/path operations and introduces AbsolutePath usage for key paths. |
src/Tasks.UnitTests/SGen_Tests.cs |
Adds tests validating the multithreaded TaskEnvironment behavior for SGen. |
| pathToTool = SdkToolsPathUtility.GeneratePathToTool( | ||
| f => !string.IsNullOrEmpty(f) | ||
| ? SdkToolsPathUtility.FileInfoExists(TaskEnvironment.GetAbsolutePath(f)) | ||
| : SdkToolsPathUtility.FileInfoExists(f), |
There was a problem hiding this comment.
in the else branch, the f is null or empty, right? why do we call the FileInfoExists in such case? won't it be always false?
There was a problem hiding this comment.
This is to fully preserve the previous behavior. Earlier, the code passed the path directly to
SdkToolsPathUtility.FileInfoExists, and if it was null, it would throw an ArgumentNullException.
… of https://github.com/OvesN/msbuild into dev/veronikao/migrate-SGen-Task-to-TaskEnvironment-API
… of https://github.com/OvesN/msbuild into dev/veronikao/migrate-SGen-Task-to-TaskEnvironment-API
|
Blocked for now, we should fix this first |
Fixes #13455
Context
The SGen task was made thread-safe.
Changes Made
SGen.cs
Testing
Unit tests in
SGen_Tests.csNotes