Repository navigation
Migrate FindAssembliesWithReferencesTo to IMultiThreadableTask - #54748
Conversation
There was a problem hiding this comment.
Pull request overview
This PR migrates the Razor SDK task FindAssembliesWithReferencesTo to MSBuild’s IMultiThreadableTask model (per dotnet/msbuild#14051), flowing TaskEnvironment through to reference scanning so file I/O resolves relative paths correctly under multi-threaded builds.
Changes:
- Mark
FindAssembliesWithReferencesToas[MSBuildMultiThreadableTask], implementIMultiThreadableTask, and passTaskEnvironmentinto the resolver. - Update
ReferenceResolverto resolve assembly paths viaTaskEnvironment.GetAbsolutePath(...)before performingFile.Exists/File.OpenRead. - Add a new
agency.tomlconfiguration file at repo root.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/RazorSdk/Tasks/ReferenceResolver.cs | Accepts TaskEnvironment and uses it to absolutize paths; refactors lookup dictionary initialization. |
| src/RazorSdk/Tasks/FindAssembliesWithReferencesTo.cs | Migrates the task to IMultiThreadableTask and flows TaskEnvironment into ReferenceResolver. |
| agency.toml | Introduces an MCP server configuration entry (appears unrelated to the PR’s stated purpose). |
Expert review —
|
jankratochvilcz
left a comment
There was a problem hiding this comment.
Thank you! The main bit for me is the architectural comment
|
Adding @chsienki and @davidwengier to review from the Razor Tooling side. |
davidwengier
left a comment
There was a problem hiding this comment.
IMO the asp.net runtime team owns all of this, but it is entirely possible that I'm wrong, or that nobody owns them, but I have no problem approving the PR regardless. Approval does not imply acceptance of ownership. You touched it last :)
|
@davidwengier The owner seems to be Sam Patel, but his team has no capacity to help with this it seems unfortunately |
jankratochvilcz
left a comment
There was a problem hiding this comment.
Thanks for making the changes! 👍
Btw. regarding the layering - for me it's less about what we expose publicaly and more about the code layering - if we can keep the resolutions on a single layer (the tasks) it also creates clear expectations for there the absolutization should happen and it becomes harder to make the wrong assumption
Got it. But I would assume that that helper class was on the task level, it just decoupled the logic from task class. 🤔 |
Fixes dotnet/msbuild#14051
What & why
MSBuild is moving toward running multiple tasks in parallel within a single process. To be safe under that model, a task must not depend on process-global state — in particular the current working directory, which a concurrently running task could change at any time. Any task that resolves relative file paths against the current directory is therefore not safe to run this way.
FindAssembliesWithReferencesTois the Razor SDK task that figures out which of a project's referenced assemblies depend (directly or transitively) on ASP.NET Core MVC. It does this by opening each referenced assembly file on disk and reading its metadata.What changed
[MSBuildMultiThreadableTask]/IMultiThreadableTask) so the MSBuild engine may run it in parallel; it now receives a per-taskTaskEnvironmentfrom the engine.TaskEnvironment.GetAbsolutePath) instead of the ambient process working directory. This is the one change needed to make the file access safe under parallel execution.