-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add binding redirects for all assemblies redistributed by MSBuild #6334
Conversation
I suspect it doesn't need to add bindingRedirects if there was no conflict and it didn't need to unify the types. This is going to start forcing tasks to run on MSBuild's assembly if the one they carry is lower, I guess that's OK. In general MSBuild shouldn't force redirection as it can have side-effects on the task (we've had MSBuild redirect us into breaking NuGet changes in the past). Tasks should see it as their own responsibility to handle redirects for their assemblies. cc @dsplaisted @rainersigwald |
Are you referring to tasks adding assembly resolve event handlers to handle redirects? AFAIK that does not work with assemblies redistributed by MSBuild because the redistributed assemblies are placed next to msbuild.exe (the appdomain's appbase) and thus the CLR does not issue resolve events for those.
Since MSBuild is redistributing this dll I assume the engine really needs it in order to function. And since the engine's dependencies are not isolated from the plugins' dependencies, they all swim in the same type space, so by choosing to redistribute a dll, MSBuild is actually forcing all plugins to use its redistributed version right? Hence the binding redirect just formalizes that and prevents accidentally loading the plugin's assembly first and potentially crashing the engine. One way or another something might crash, and it's probably better if it's not the engine? |
It should still issue the event. Only time it doesn't raise the event is when the assembly loads correctly (in which case you didn't need the redirect). I did a quick test and a DLL with matching name and wrong version will raise the event.
They could load a version side-by-side in the same app domain, which is fine so long as they don't need to exchange the types with MSBuild.
Why would that crash? Your change may still be OK, but I think it should be more complete by establishing a crisper stance about how to think about these dependencies. For instance: MSBuild will provide assemblies X, Y, Z etc. You don't need to include these with your tasks. Just reference packages X, Y, Z versions NNN and exclude them from your package. In fact, I bet MSBuild could provide a single PackageReference that represents what's "safe" for tasks to use without redistributing for a specific version of MSBuild. I'd really like to hear from the SDK team on this as this is something they've faced for years. @dsplaisted @wli3 |
We've accidentally shipped binding redirects before when we have a conflict that |
fc14926
to
cf8250e
Compare
Redirected all assemblies redistributed by the msbuild .vsix package. |
OverlappingBuildsOfTheSameProjectDifferentTargetsAreAllowed seems to be the failing test. I don't know why it would've failed, so I started it running again. |
As far as I can tell it passed a VS insertion: https://devdiv.visualstudio.com/DevDiv/_git/VS/pullrequest/318516 |
I'm a little confused about that PR, actually. Request perf ddrits succeeded, but I don't see RPS as having run in the list of checks where I'd expect it. There was something else perf-y in the list, but I'm not sure whether that was the same or not. I requeued request perf ddrits, and we'll see if that does anything different. |
@Forgind I did a new insertion PR and it passed: https://devdiv.visualstudio.com/DevDiv/_git/VS/pullrequest/319415 |
eng/Packages.props
Outdated
@@ -1,4 +1,8 @@ | |||
<Project> | |||
<!-- | |||
Make sure to update the binding redirects (in src\MSBuild\app.config) for any changes to |
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.
👍👍👍👍
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.
Updated to include the 64bit appconfig in that comment as well :)
…tnet#6334) MSBuild redistributes System.Memory but does not binding redirect it. This causes the QB cache plugin to fail (qb.exe works because it has binding redirects, but the plugin fails because it's a dll and dlls don't have binding redirects). Both MSBuild and VS ship with System.Memory 4.0.1.1 so this should not have any negative consequences.
) MSBuild redistributes System.Memory but does not binding redirect it. This causes the QB cache plugin to fail (qb.exe works because it has binding redirects, but the plugin fails because it's a dll and dlls don't have binding redirects). Both MSBuild and VS ship with System.Memory 4.0.1.1 so this should not have any negative consequences.
MSBuild redistributes System.Memory but does not binding redirect it. This causes the QB cache plugin to fail (qb.exe works because it has binding redirects, but the plugin fails because it's a dll and dlls don't have binding redirects).
Both MSBuild and VS ship with System.Memory 4.0.1.1 so this should not have any negative consequences.
In general, shouldn't MSBuild add binding redirects for all the assemblies that it redistributes? I see that MSBuild redistributes a bunch of assemblies but does not binding redirect them. @danmoseley @ericstj