Repository navigation
Migrate Arcade.Sdk and Helix tasks to the multithreaded task model - #17525
Conversation
Annotates 18 tasks across Microsoft.DotNet.Arcade.Sdk and Microsoft.DotNet.Helix with [MSBuildMultiThreadableTask] and routes their path and environment access through TaskEnvironment. - XHarnessTaskBase carries IMultiThreadableTask so the shared base members fall under the analyzer, while the attribute stays on the two concrete tasks, since routing keys off the attribute alone. - SingleError stays out: its GetRegisteredTaskObject/RegisterTaskObject pair is not atomic, so concurrent instances could both log, defeating its contract. - SendHelixJob and InstallDotNetTool implement the interface without the attribute so they keep routing through the TaskHost; both reach process-wide state that path resolution alone cannot make safe. - LocateDotNet keeps Path.GetFullPath on the resolved path so the DotNetPath output stays canonical, and skips malformed PATH entries rather than throwing. - FindDotNetCliPackage._client is no longer static. It was reassigned on every execution, so sharing it across instances was a race, not pooling. Co-authored-by: Copilot <[email protected]> Copilot-Session: be19d794-fe4f-43fe-9e6e-f6e6b13ec6e7
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Several newly introduced TaskEnvironment.GetAbsolutePath(...) call sites can throw on empty/malformed user input where the previous behavior was a non-throwing existence check, risking hard build failures.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review tier: Lite
Findings: 4
New issues introduced by this change (4)
| Severity | Finding |
|---|---|
src/Microsoft.DotNet.Arcade.Sdk/src/DownloadFile.cs — In the file:// copy path, TaskEnvironment.GetAbsolutePath(filePath) can throw for malformed… |
|
src/Microsoft.DotNet.Helix/Sdk/CreateXHarnessAndroidWorkItems.cs — apkPath = TaskEnvironment.GetAbsolutePath(apkPath) can throw if the item spec/metadata is empty… |
|
src/Microsoft.DotNet.Helix/Sdk/CreateXHarnessAppleWorkItems.cs — appFolderPath = TaskEnvironment.GetAbsolutePath(appFolderPath) can throw if the item… |
|
src/Microsoft.DotNet.Helix/Sdk/SendHelixJob.cs — TaskEnvironment.GetAbsolutePath(path) will throw for empty or malformed item specs, whereas the… |
What changed in this PR
Migrates a set of Microsoft.DotNet.Arcade.Sdk and Microsoft.DotNet.Helix MSBuild tasks toward MSBuild’s multithreaded task model by opting tasks into [MSBuildMultiThreadableTask], implementing IMultiThreadableTask, and routing path/environment resolution through TaskEnvironment to make per-project execution safer under -mt.
Changes:
- Annotate additional tasks as multithreadable and/or implement
IMultiThreadableTaskto enableTaskEnvironmentinjection. - Replace direct path/environment usage with
TaskEnvironment-based resolution, and adjust Helix XHarness behavior (including test expectations) for absolute payload paths. - Update process spawning and IO call sites to avoid binding to process-wide state in multithreaded/shared-node scenarios.
| File | Description |
|---|---|
| src/Microsoft.DotNet.Helix/Sdk/XharnessTaskBase.cs | Makes shared XHarness base participate in IMultiThreadableTask/TaskEnvironment injection. |
| src/Microsoft.DotNet.Helix/Sdk/SendHelixJob.cs | Uses TaskEnvironment for env/path resolution while intentionally keeping TaskHost routing. |
| src/Microsoft.DotNet.Helix/Sdk/InstallDotNetTool.cs | Injects TaskEnvironment for path resolution while intentionally keeping TaskHost routing. |
| src/Microsoft.DotNet.Helix/Sdk/FindDotNetCliPackage.cs | Marks task multithreadable and removes static client to avoid cross-instance races. |
| src/Microsoft.DotNet.Helix/Sdk/DownloadFromResultsContainer.cs | Opts into multithreading and resolves output paths via TaskEnvironment. |
| src/Microsoft.DotNet.Helix/Sdk/CreateXHarnessAppleWorkItems.cs | Opts into multithreading and resolves bundle/tmp paths via TaskEnvironment. |
| src/Microsoft.DotNet.Helix/Sdk/CreateXHarnessAndroidWorkItems.cs | Opts into multithreading and resolves APK paths via TaskEnvironment. |
| src/Microsoft.DotNet.Helix/Sdk/BaseTask.cs | Minor cleanup of base task type reference/import. |
| src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/CreateXHarnessAppleWorkItemsTests.cs | Updates tests for absolute-path payload behavior. |
| src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/CreateXHarnessAndroidWorkItemsTests.cs | Updates tests for absolute-path payload behavior. |
| src/Microsoft.DotNet.Arcade.Sdk/src/ValidateLicense.cs | Opts into multithreading and resolves inputs via TaskEnvironment. |
| src/Microsoft.DotNet.Arcade.Sdk/src/Unsign.cs | Opts into multithreading and resolves file path via TaskEnvironment. |
| src/Microsoft.DotNet.Arcade.Sdk/src/SingleError.cs | Documents why task is not opted into multithreading; keeps behavior consistent. |
| src/Microsoft.DotNet.Arcade.Sdk/src/SetCorFlags.cs | Opts into multithreading and resolves file path via TaskEnvironment. |
| src/Microsoft.DotNet.Arcade.Sdk/src/SaveItems.cs | Opts into multithreading and resolves output path via TaskEnvironment. |
| src/Microsoft.DotNet.Arcade.Sdk/src/LocateDotNet.cs | Opts into multithreading and moves PATH/global.json resolution through TaskEnvironment. |
| src/Microsoft.DotNet.Arcade.Sdk/src/InstallDotNetCore.cs | Opts into multithreading and starts dotnet-install using TaskEnvironment start info. |
| src/Microsoft.DotNet.Arcade.Sdk/src/GetLicenseFilePath.cs | Opts into multithreading and resolves search directory via TaskEnvironment. |
| src/Microsoft.DotNet.Arcade.Sdk/src/GetAssemblyFullName.cs | Opts into multithreading and resolves assembly paths via TaskEnvironment. |
| src/Microsoft.DotNet.Arcade.Sdk/src/GenerateSourcePackageSourceLinkTargetsFile.cs | Opts into multithreading and resolves output path via TaskEnvironment. |
| src/Microsoft.DotNet.Arcade.Sdk/src/GenerateResxSource.cs | Opts into multithreading and resolves input/output paths via TaskEnvironment. |
| src/Microsoft.DotNet.Arcade.Sdk/src/GenerateChecksums.cs | Opts into multithreading and resolves item/destination paths via TaskEnvironment. |
| src/Microsoft.DotNet.Arcade.Sdk/src/ExtractNgenMethodList.cs | Opts into multithreading and resolves input/output paths via TaskEnvironment. |
| src/Microsoft.DotNet.Arcade.Sdk/src/DownloadFile.cs | Opts into multithreading and resolves destination/source paths via TaskEnvironment. |
| src/Microsoft.DotNet.Arcade.Sdk/src/CheckRequiredDotNetVersion.cs | Opts into multithreading and resolves global.json path via TaskEnvironment. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
GetAbsolutePath rejects a null or empty path, whereas the File/Directory existence probes it replaced simply returned false. Where the path is user-supplied, keep reporting the existing "not found" error rather than throwing. - SendHelixJob: correlation payload paths come from GetMetadata, which yields an empty string for absent metadata. - CreateXHarnessAndroidWorkItems / CreateXHarnessAppleWorkItems: payload paths come from item metadata, and the Apple task's TrimEnd can itself empty the string for a path that is only a separator. - Adds a regression test pinning the Android empty-path behavior. LocateDotNet drops the try/catch added for malformed PATH entries. The two argument AbsolutePath constructor only rejects null and empty, and splitting PATH with RemoveEmptyEntries already rules those out, so the catch was unreachable and its stated rationale wrong. Co-authored-by: Copilot <[email protected]> Copilot-Session: be19d794-fe4f-43fe-9e6e-f6e6b13ec6e7
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
A few updated tasks now resolve paths via TaskEnvironment but still log raw (possibly relative) inputs or log the wrong executable, which can mislead diagnostics and should be corrected.
Review tier: Lite
Findings: None
Issues resolved since last review (4)
| Severity | Finding |
|---|---|
src/Microsoft.DotNet.Helix/Sdk/SendHelixJob.cs — TaskEnvironment.GetAbsolutePath(path) will throw for empty or malformed item specs, whereas the… View resolved comment |
|
src/Microsoft.DotNet.Helix/Sdk/CreateXHarnessAppleWorkItems.cs — appFolderPath = TaskEnvironment.GetAbsolutePath(appFolderPath) can throw if the item… View resolved comment |
|
src/Microsoft.DotNet.Helix/Sdk/CreateXHarnessAndroidWorkItems.cs — apkPath = TaskEnvironment.GetAbsolutePath(apkPath) can throw if the item spec/metadata is empty… View resolved comment |
|
src/Microsoft.DotNet.Arcade.Sdk/src/DownloadFile.cs — In the file:// copy path, TaskEnvironment.GetAbsolutePath(filePath) can throw for malformed… View resolved comment |
Suppressed comments (3)
Previously missed (3) — in code that hasn't changed since the last review.
src/Microsoft.DotNet.Arcade.Sdk/src/GetLicenseFilePath.cs:50
- The directory being searched is now resolved via
TaskEnvironment.GetAbsolutePath(Directory), but the error messages still print the rawDirectoryvalue. IfDirectoryis relative, this can be confusing; log the resolveddirectoryso the message matches the actual search location.
src/Microsoft.DotNet.Arcade.Sdk/src/ValidateLicense.cs:38 - The task resolves input paths via
TaskEnvironment.GetAbsolutePath(...), but the mismatch error logs the rawLicensePath/ExpectedLicensePathvalues. If those are relative, the error message won’t reflect the actual files compared; log the resolved paths for clarity.
src/Microsoft.DotNet.Helix/Sdk/InstallDotNetTool.cs:181 - The log line uses
DotnetPath, but the command actually runsexecutable(eitherdotnetfrom PATH or an absolute path resolved viaTaskEnvironment). WhenDotnetPathis empty or relative, this message can be misleading for diagnostics; logexecutableinstead.
The repo sets csharp_new_line_before_open_brace = all, but DownloadFile.cs carries some older K&R style. Bring the three lines this PR already modifies into line with the repo style. No behavior change. Co-authored-by: Copilot <[email protected]> Copilot-Session: be19d794-fe4f-43fe-9e6e-f6e6b13ec6e7
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
DownloadFromResultsContainer can throw when asked to download a filename without directory separators, which can crash the task for valid inputs.
Review tier: Lite
Findings: None
Suppressed comments (4)
Previously missed (3) — in code that hasn't changed since the last review.
src/Microsoft.DotNet.Arcade.Sdk/src/InstallDotNetCore.cs:98
- When
VersionsPropsPathis null/empty, the error message becomes "Unable to find translation file " (blank path), which makes it hard to diagnose the real problem (missing property value). Consider an explicit message thatVersionsPropsPathwas not provided.
src/Microsoft.DotNet.Helix/Sdk/InstallDotNetTool.cs:181 - The log message uses
DotnetPath, but the command actually executesexecutable(either "dotnet" or an absolute path). WhenDotnetPathis empty this currently logs an empty executable, and when it’s relative the log won’t match what is executed; loggingexecutablemakes troubleshooting reliable.
src/Microsoft.DotNet.Helix/Sdk/XharnessTaskBase.cs:15 - The XML summary says this base task is for Android packages, but it’s also the shared base for the Apple work item task. Updating the summary avoids misleading API documentation and search results.
src/Microsoft.DotNet.Helix/Sdk/DownloadFromResultsContainer.cs:85
Path.GetDirectoryName(file)returns null whenfileis just a filename (no directory separators).Path.Combine(destinationDir.FullName, null)will then throw, which can crash the task for validDownloadFilesFromResultsvalues like "results.xml". Guard the directory creation for the no-subdirectory case.
DirectoryInfo destinationDir = Directory.CreateDirectory(TaskEnvironment.GetAbsolutePath(Path.Combine(directoryPath, workItemName)));
foreach (string file in filesToDownload)
{
try
{
Replaces the local MSBuildTask0002 suppression with the existing AbsolutePathExtensions.GetCanonicalForm polyfill, which Templating, CMake.Sdk and XliffTasks already use for exactly this case. The suppression now lives in one place, tracked by dotnet#17506, instead of being duplicated per call site. Behavior is unchanged: the polyfill is Path.GetFullPath over an already fully qualified path, which is what the previous code computed. Co-authored-by: Copilot <[email protected]> Copilot-Session: be19d794-fe4f-43fe-9e6e-f6e6b13ec6e7
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The changes affect MSBuild task routing/execution semantics across core Arcade/Helix tasks under multi-threaded builds, so a final human review is needed despite only minor localized issues found.
Review tier: Lite
Findings: None
Suppressed comments (3)
Previously missed (3) — in code that hasn't changed since the last review.
src/Microsoft.DotNet.Arcade.Sdk/src/ValidateLicense.cs:41
- This task now resolves inputs via
TaskEnvironment, so the error message can point at different (resolved) files than the rawLicensePath/ExpectedLicensePathvalues. Logging the resolved paths makes mismatches easier to diagnose when inputs are relative.
var expectedLines = File.ReadAllLines(TaskEnvironment.GetAbsolutePath(ExpectedLicensePath), Encoding.UTF8);
if (!LinesEqual(actualLines, expectedLines))
{
Log.LogError($"License file content '{LicensePath}' doesn't match the expected license '{ExpectedLicensePath}'.");
src/Microsoft.DotNet.Arcade.Sdk/src/InstallDotNetCore.cs:98
- When
VersionsPropsPathis empty, the current error message prints a blank path, which makes it hard to diagnose what needs to be set. Consider an explicit message stating thatVersionsPropsPathmust be provided.
src/Microsoft.DotNet.Helix/Sdk/InstallDotNetTool.cs:181 - The log line uses
DotnetPath, but the actual executable may be the literal "dotnet" (whenDotnetPathis empty) or an absolutized path. This can produce misleading logs likeExecuting ...even though the task randotnet ....
Fixes the diagnostics flagged in the collapsed "Suppressed comments" sections of the Copilot reviews, plus the path-inflation cases those reviews missed: - InstallDotNetTool: the "Executing" message printed DotnetPath, which is empty in the common case, so it reported a blank command while actually running "dotnet". Log the executable that is really invoked. - InstallDotNetCore: an empty VersionsPropsPath produced "Unable to find translation file " with no path. Give it an explicit message instead. - InstallDotNetCore: revert four messages that had been switched from the user-supplied property to the absolutized local. Per the migration guidance, "cannot find" diagnostics must echo the value the user wrote, not the resolved form. The "Executing:"/"Command:" lines keep the resolved path, since those report what was actually run. - XHarnessTaskBase: the XML summary described Android only; it is the shared base for both Android and Apple.
|
Went back through the collapsed Suppressed comments sections of the Copilot reviews (they don't surface as resolvable threads). Six distinct findings; four addressed in 9ce7cc9, two declined with evidence. Fixed1. Valid, and this PR made it worse. 2. Valid. The 3. Valid; it is the shared base for Android and Apple. Corrected. 4. (not reported) Path inflation in Auditing the above turned up four messages this PR had switched from the user-supplied property to the absolutized local, e.g. Declined5. The premise is incorrect.
6. Declining deliberately: this is the opposite of the guidance. Diagnostics are supposed to echo the value the user supplied, so that |
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Two confirmed edge-case bugs can still cause unhandled exceptions (PATH unset in LocateDotNet and null directory name handling in results download path creation).
Review tier: Lite
Findings: None
Suppressed comments (2)
Previously missed (2) — in code that hasn't changed since the last review.
src/Microsoft.DotNet.Arcade.Sdk/src/LocateDotNet.cs:38
- If PATH is unset/empty in the task's environment, paths.Split(...) will throw a NullReferenceException. This should fail gracefully with a clear error since locating dotnet depends on PATH.
src/Microsoft.DotNet.Helix/Sdk/DownloadFromResultsContainer.cs:81 - Path.GetDirectoryName(file) can return null when the requested file has no directory component (e.g., "stdout.txt"), which would make Path.Combine(..., null) throw later in this loop and fail the download. Guard the directory creation so plain filenames work.
The previous commit fixed only the braces on lines this PR already touched, which left the file internally inconsistent. These three were pre-existing K&R and are the last ones in the file; it is now uniformly Allman, per csharp_new_line_before_open_brace = all. Whitespace-only: the file is token-identical to its parent once all whitespace is stripped.
TaskEnvironment.GetEnvironmentVariable is declared nullable, and the multithreaded driver resolves it against a per-project environment dictionary rather than the process block, so a missing PATH returns null more readily than the previous Environment.GetEnvironmentVariable did. paths.Split then threw a NullReferenceException. Guard before the cache key is built so an empty PATH also reports this rather than the misleading "unable to find dotnet with SDK version".
|
Latest review's suppressed section had two findings — one real, one a repeat. Fixed: Correct. Guarded in c2e7325, placed before the cache key is constructed. Using Declining again: This is the same finding from the previous review, moved to a different line number. It remains incorrect, now against its own new example:
|
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
LocateDotNet can crash with a NullReferenceException if PATH is unset/empty, and should instead log a clear error and return.
Review tier: Lite
Findings: None
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
src/Microsoft.DotNet.Arcade.Sdk/src/LocateDotNet.cs:38
TaskEnvironment.GetEnvironmentVariable("PATH")can return null/empty; the subsequentpaths.Split(...)will throwNullReferenceExceptionand hard-fail the task. Consider handling a missing PATH explicitly and logging a clear error instead of crashing.
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
GenerateChecksums now calls TaskEnvironment.GetAbsolutePath(item.ItemSpec) without guarding against an empty item spec, which can turn the previous “file missing” error path into an exception-based failure.
Review tier: Lite
Findings: None
Suppressed comments (2)
Previously missed (2) — in code that hasn't changed since the last review.
src/Microsoft.DotNet.Arcade.Sdk/src/GenerateChecksums.cs:41
TaskEnvironment.GetAbsolutePath(item.ItemSpec)throws for an empty item spec, which changes the failure mode from the existing "file does not exist" error into an exception-based failure. SinceItemsis user-supplied, it’s safer to keep the explicit missing-file error path for empty specs too.
src/Microsoft.DotNet.Helix/Sdk/InstallDotNetTool.cs:119versionis normalized to lower-case butToolPathis still built withVersion. On case-sensitive file systems this can defeat the "same tool/version" deduplication (mutex key and directory) for semantically identical versions differing only by case, and it makes the lower-casing logic easy to misread as dead code.
…cksums File.Exists returned false for an empty item spec, so the task reported "The file '' does not exist." GetAbsolutePath throws instead, and while the surrounding try/catch keeps that from crashing the build, it replaced the diagnostic with "The value cannot be an empty string. (Parameter 'path')". Guard so the original error path is kept. Items is ITaskItem[], so [Required] validates only that the collection is non-empty; an individual ItemSpec can still be empty. The remaining path inputs across this PR are [Required] scalars, which MSBuild rejects before Execute runs.
|
Two findings this round, both against the current head. Fixed: Correct, and a genuine regression from this PR. This one is reachable precisely because Since this is the fourth report of this class, I swept every
Declining: This is unchanged from var version = Version.ToLowerInvariant();
ToolPath = Path.Combine(DestinationPath, Name, Version);
string versionInstallPath = Path.Combine(ToolPath, ".store", Name.ToLowerInvariant(), version);This PR only replaced |
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The changes are broad and concurrency-sensitive (task routing, environment/path scoping, and process invocation), so a final human review is advisable even though the diff looks internally consistent.
Review tier: Lite
Findings: None
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Existing InstallDotNetTool tests use Windows-only path literals and will fail on non-Windows hosts after path resolution.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review tier: Balanced
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
src/Microsoft.DotNet.Helix/Sdk/InstallDotNetTool.cs — This makes the existing cross-platform InstallDotNetToolTests fail on non-Windows hosts. The… |
Suppressed comments (1)
src/Microsoft.DotNet.Helix/Sdk/InstallDotNetTool.cs:180
- The explicit-path test sets
DotnetPathtoD:\dotnet\dotnet.exeon every OS and configures the command mock to expect that exact string. On Unix, this new resolution treats it as relative and passes<project>/D:\dotnet\dotnet.exe, soInstallsToolWithExtraParamsSuccessfullyno longer matches the mock. Please use a host-native absolute executable path in that test or compute the expected value through the task environment.
// A bare "dotnet" is resolved through PATH by the process launcher and must stay
// unresolved; only an explicitly supplied path is made absolute.
var executable = string.IsNullOrEmpty(DotnetPath) ? "dotnet" : (string)TaskEnvironment.GetAbsolutePath(DotnetPath);
The task now resolves DestinationPath and DotnetPath through TaskEnvironment. The fixture used "C:\dotnet_tools" and "D:\dotnet\dotnet.exe", which are absolute only on Windows; on Unix neither is rooted, so resolution prefixes the project directory and the ToolPath assertions, the --tool-path argument and the ICommandFactory mock expectation all stop matching. Build the paths from Path.GetTempPath() instead, which is absolute on every host, so the resolved value is identical to the literal. Nothing is written to these paths; the file system is mocked.
|
Good catch, and the most consequential finding so far — fixed in c263858.
Both are now built from Verified 304/304 green on Windows, including all 6 I also swept for the same class rather than handle it one report at a time: across both changed files and the full Worth noting for the remaining subsets of this migration, since it generalizes beyond this PR: absolutizing a task input turns any Windows-shaped test literal into a silent cross-platform failure, because such a literal is valid but relative on Unix rather than an error. Test fixtures for migrated tasks need host-native paths. |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The PATH-based DotNetTool fallback is incorrectly converted into a project-relative path.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review tier: Balanced
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
src/Microsoft.DotNet.Helix/Sdk/InstallDotNetTool.cs — When Arcade's repo-local .dotnet directory is absent, RepoLayout.props:18-22 intentionally sets… |
Issues resolved since last review (1)
| Severity | Finding |
|---|---|
src/Microsoft.DotNet.Helix/Sdk/InstallDotNetTool.cs — This makes the existing cross-platform InstallDotNetToolTests fail on non-Windows hosts. The… View resolved comment |
RepoLayout.props clears DotNetRoot when the repo-local .NET install is
absent ("Let the exec task find dotnet on PATH"), which leaves DotNetTool
as a bare "dotnet"/"dotnet.exe". XHarnessRunner.targets forwards that as
DotnetPath, so it is non-empty and the previous change absolutized it into
<project>/dotnet.exe, breaking XHarness tool installation in that
supported fallback configuration.
Only absolutize when the value carries a directory component. A bare
executable name is passed through so the process launcher resolves it on
PATH, which is also how Tests.targets treats DotNetTool (it guards with
IsPathRooted before deriving a host directory from it).
Adds a regression test; without the fix it fails with a
NullReferenceException, because the command factory never matches the
absolutized name.
|
Confirmed and fixed in d5759ec. This was a real regression in a supported configuration, and my own code comment claimed to handle the case it actually got wrong.
<DotNetRoot Condition="!Exists($(DotNetRoot))"/>
<DotNetTool Condition="'$(OS)' == 'Windows_NT'">$(DotNetRoot)dotnet.exe</DotNetTool>so The fix absolutizes only when the value carries a directory component: if (string.IsNullOrEmpty(DotnetPath)) executable = "dotnet";
else if (string.IsNullOrEmpty(Path.GetDirectoryName(DotnetPath))) executable = DotnetPath;
else executable = TaskEnvironment.GetAbsolutePath(DotnetPath);This matches how the rest of the repo treats the property — Added I also swept for the same class rather than wait for another report. Generalizing for the remaining subsets: a task input that names an executable must not be absolutized unconditionally, because a bare name is a legitimate value meaning "resolve on PATH". That is a distinct hazard from the empty-path one, since the value is non-empty and looks perfectly valid. |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The migration consistently isolates project-scoped state, preserves intentional exclusions, and includes targeted regression coverage.
Review tier: Balanced
Findings: None
Issues resolved since last review (1)
| Severity | Finding |
|---|---|
src/Microsoft.DotNet.Helix/Sdk/InstallDotNetTool.cs — When Arcade's repo-local .dotnet directory is absent, RepoLayout.props:18-22 intentionally sets… View resolved comment |
…sPath errors The comment on SendHelixJob claimed the task cannot be multithreaded because JobDefinition reads BUILD_REPOSITORY_NAME, BUILD_SOURCEBRANCH, SYSTEM_TEAMPROJECT and BUILD_REASON from Environment. Those are Azure Pipelines build-level variables, set once by the agent for the whole process, so they do not vary per project and no job can be tagged with another project's metadata. The real reason to hold this task back is that the JobSender and HelixApi stack has not been audited for shared mutable state. Also replaces "translation file" with wording that matches the neighbouring errors, which already refer to the properties defined in VersionsPropsPath.


Sixth safe subset of #17381:
Microsoft.DotNet.Arcade.SdkandMicrosoft.DotNet.Helix. Two independent assemblies, both with in-repo test suites.18 tasks annotated with
[MSBuildMultiThreadableTask]; paths and environment reads go throughTaskEnvironment.XHarnessTaskBaseimplementsIMultiThreadableTaskso the shared base members come under analyzer coverage, while the attribute stays on the two concrete tasks — routing keys off the attribute alone.SingleErrordeliberately stays out:GetRegisteredTaskObject/RegisterTaskObjectis not atomic, so concurrent instances with the sameTextcould both log, defeating the single-error contract.SendHelixJobandInstallDotNetToolimplement the interface without the attribute, so they keep routing through the TaskHost.InstallDotNetToollaunches a child process throughICommandFactory, which builds itsProcessStartInfofrom the ambient environment rather than the project's.SendHelixJobreaches theJobSender/HelixApistack, which has not been audited for shared mutable state and is the most side-effecting task in the SDK; tracked for a follow-up change.LocateDotNetcanonicalizes the resolved path withGetCanonicalForm()so theDotNetPathoutput keeps the shape the previousPath.GetFullPathproduced —GetAbsolutePathanchors, it does not normalize. It also skips malformedPATHentries instead of throwing, sinceGetAbsolutePathvalidates where the previousFile.Existsprobe just returned false, and reports a clear error whenPATHis unset.InstallDotNetCoreswitches toTaskEnvironment.GetProcessStartInfo()so the childdotnet-installinherits the project's environment.FindDotNetCliPackage._clientis no longerstatic. It was reassigned on every execution, so sharing it across instances was a race rather than pooling.DotNetToolbecomes plaindotnet.exewhenRepoLayout.propsclearsDotNetRoot) is left unresolved so it still resolves onPATH.Validation
CentralPackageManagementTestsfailure (SwixBuild NU1009) that this PR does not touch.MSBuildTask0003/MSBuildTask0002, confirming the analyzer is live and the clean run is meaningful.