Skip to content
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

AssemblyLoadContext-related task errors in 16.5 #5202

Closed
6 of 7 tasks
rainersigwald opened this issue Mar 26, 2020 · 6 comments
Closed
6 of 7 tasks

AssemblyLoadContext-related task errors in 16.5 #5202

rainersigwald opened this issue Mar 26, 2020 · 6 comments
Assignees
Labels
Area: Engine Issues impacting the core execution of targets and tasks. regression triaged

Comments

@rainersigwald
Copy link
Member

rainersigwald commented Mar 26, 2020

Background

Before 3.1.200, MSBuild tasks and their dependencies were loaded into the default ALC. Since an ALC can have only one assembly loaded for the same name (not including version), this forced all tasks to use the same version of dependencies, and that version had to match the one delivered in the .NET Core SDK (if the assembly was there). This was very annoying and broke people.

In MSBuild 16.5/SDK 3.1.200, we isolated plugins in their own ALC (#4916). We planned to extend this in the .NET 5 timeframe to use an AssemblyDependencyResolver, to further improve the situation for native dependencies (#5037).

There is an environment-variable-based workaround MSBUILDSINGLELOADCONTEXT=1 available to revert to the previous behavior.

Problems

This change broke some tasks that use reflection or fancy assembly loading inside the task implementation. All users of affected tasks are broken, not just the maintainers of the tasks.

Known failures are:

• GitVersionTask (457 NuGet downloads/day)
• Fody <6.0.4 (2730 downloads/day, but I don’t know the version breakdown)
• SpecFlow (3215 downloads/day)
• MSBump (92 downloads/day, repo archived)

Related issues

@rainersigwald rainersigwald added regression Area: Engine Issues impacting the core execution of targets and tasks. labels Mar 26, 2020
@rainersigwald rainersigwald added this to the MSBuild 16.6 Preview 3 milestone Mar 26, 2020
@rainersigwald rainersigwald self-assigned this Mar 26, 2020
@rainersigwald
Copy link
Member Author

Figured out the SpecFlow case: SpecFlowOSS/SpecFlow#1912 (comment).

In short, this is an expected behavior of Assembly.LoadFile that was sort of worked around before because MSBuild could find dependencies in AssemblyLoadContext.Default.

@AArnott
Copy link
Contributor

AArnott commented Apr 16, 2020

@rainersigwald It turns out it isn't solved by coverlet.msbuild 2.8.1. This PR is blocked in updating to .NET SDK 3.1.201 because of this same break, and updating coverlet didn't fix it. So I'm still blocked.

dotnet/Nerdbank.Streams#180

@rainersigwald
Copy link
Member Author

@AArnott sorry it took me a while to get to this, but I don't see anything that looks like an MSBuild task failure in that PR. Can you point me to what you think is failing?

@AArnott
Copy link
Contributor

AArnott commented Apr 24, 2020

Quite right. I forgot in that PR that updating to coverlet.msbuild 2.8.1 also changes the filenames of the coverage files generated, so there's more to adapting to the task loader change than just updating the package reference.

@rainersigwald
Copy link
Member Author

Closing: all of the known active-development tasks that had problems have been fixed in new releases.

@marcpopMSFT
Copy link
Member

For gitversion, recent exceptions customers have been facing have been the below: Adding a comment to help with customer searches.
Error Exception in initialization: System.IO.FileNotFoundException: Could not load file or assembly ‘System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51’ or one of its dependencies. The system cannot find the file specified.

@AR-May AR-May added the triaged label Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Engine Issues impacting the core execution of targets and tasks. regression triaged
Projects
None yet
Development

No branches or pull requests

4 participants