Repository navigation
Conversation
…rk build The [MSBuildMultiThreadableTask] marker attribute only exists in Microsoft.Build.Framework 18.6 and later. The .NET (SDK) build of NuGet's MSBuild tasks gets it from the package, but the .NET Framework build compiles against the in-box MSBuild reference assemblies, which do not contain the type. This adds a self-defined compatibility shim (guarded by #if NETFRAMEWORK, in the Microsoft.Build.Framework namespace) so the shared task source can apply the marker without conditional compilation at every task. MSBuild detects the attribute by namespace and name only, so the shim is recognized by 18.6+ hosts and ignored by older ones. This is a prerequisite for migrating relative-path-resolving restore tasks to the multithreadable execution model. Co-authored-by: Copilot <[email protected]>
Mark the task with [MSBuildMultiThreadableTask] and, on the .NET (SDK) build, implement IMultiThreadableTask. The project reference path is now resolved with TaskEnvironment.GetAbsolutePath (rooted at the project directory) instead of Path.GetFullPath (rooted at the process current directory), so the task is correct when MSBuild runs it in-process during multithreaded builds. The .NET Framework build keeps the original Path.GetFullPath behavior. Adds a net10.0 test asserting the reference path resolves against the project directory rather than the current directory. Co-authored-by: Copilot <[email protected]>
Contributor
Author
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#14183
What & why
MSBuild 18.6 can run tasks in-process during multithreaded builds (
dotnet build -mt).GetRestoreProjectReferencesTaskresolved each project reference withPath.GetFullPath, which depends on the process current directory — incorrect when the task shares a long-lived process. This migrates it to the multithreadable model.Changes
[MSBuildMultiThreadableTask]; implementIMultiThreadableTaskon the .NET (SDK) build.TaskEnvironment.GetAbsolutePath(project directory) instead ofPath.GetFullPath(current directory). The .NET Framework build keeps the original behavior.[MSBuildMultiThreadableTask]attribute polyfill for the .NET Framework build (separate commit) so the marker compiles against the in-box MSBuild facade.