-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Enlighten ResolveNonMSBuildProjectOutput for multithreaded mode #13614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ namespace Microsoft.Build.Tasks | |
| /// references (i.e. calling into specific targets of references to get the manifest file name) | ||
| /// which would not be possible with a mixed list of MSBuild and non-MSBuild references. | ||
| /// </remarks> | ||
| [MSBuildMultiThreadableTask] | ||
| public class ResolveNonMSBuildProjectOutput : ResolveProjectBase | ||
|
Comment on lines
+25
to
26
|
||
| { | ||
| #region Constructors | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before marking this task as multi-threadable, please verify it doesn’t rely on process-global state for relative path resolution. The task calls GetAssemblyName(resolvedPath.ItemSpec) where resolvedPath comes from the XML inner text (not item FullPath), and existing unit tests build that XML with relative paths (e.g., "obj\correct.dll"). In in-proc multi-threaded execution, relative paths implicitly depend on Environment.CurrentDirectory and can become non-deterministic if any concurrently-running task changes it. Consider requiring/validating rooted paths for PreresolvedProjectOutputs (or normalizing to an absolute path via FileUtilities/TaskEnvironment) before enabling [MSBuildMultiThreadableTask].
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch on the careful audit. The relative-path test inputs are unit-test artifacts; in production,
PreresolvedProjectOutputsis generated by Visual Studio and always contains absolute paths (the IDE pre-resolves them precisely so MSBuild doesn't have to). The XML schema is set by the VS project system and the path values come from the IDE's resolved project output cache — there's no code path that would inject a relative path here in real builds.That said, normalizing inside the task would protect against:
PreresolvedProjectOutputswith relative paths (theoretical, no known consumer)I'd argue against doing it in this PR for two reasons:
TaskEnvironment.GetAbsolutePath()would change the value flowing intoAssemblyName.GetAssemblyName()and into the[Output] ResolvedOutputPathsitems (Sin 1 risk — the resolved path is consumed downstream by the targets). That's a separate, independently-justified change.If the multithreaded execution model needs stronger guarantees here, a follow-up issue could (a) document the contract that
PreresolvedProjectOutputsmust contain absolute paths, or (b) add normalization with explicit[Output]preservation per Sin 1. Happy to file that follow-up if reviewers think it's worthwhile.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About behavioral change risk: how so calling AssemblyName.GetAssemblyName() with absolutized path violates the sin 1? Value from AssemblyName.GetAssemblyName() does not go to [Output] ResolvedOutputPaths, we discard it.
I do not really see the reason not to be defensive here and do not use the absolutized path in GetAssemblyName
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About PreresolvedProjectOutputs - same comment as here #13615 (comment)