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

EF package broken with devDependency flag explicitly setting exclude=Runtime for PackageReference #6753

Closed
jainaashish opened this issue Mar 29, 2018 · 5 comments

Comments

@jainaashish
Copy link
Contributor

From dotnet/efcore#11437

  1. You have a tool like the EF commands (Add-Migration PMC command or dotnet ef), or the xUnit.net test runner, the MVC scaffolding, etc.
  2. You need an entry point into the user's project to reflect over and invoke their code to get their DbContext model, test classes, controllers, etc. This entry point is distributed in a NuGet package with developmentDependency="true" so it doesn't get published to the server or referenced by other projects. This is our Microsoft.EntityFrameworkCore.Design package (brought in transitively by the Microsoft.EntityFrameworkCore.Tools package). You want this assembly brought in alongside the runtime assemblies so it can take advantage of NuGet's version resolution and binding redirect logic.
  3. Your tool loads the assembly (Assembly.Load()) in the context of the user's project (e.g. using it's App.config). On .NET Framework, we use a separate AppDomain with the project's App.config file to apply appropriate binding redirects. In this case, the assembly just needs to be in the bin folder to work. On .NET Core, we start a new process using the user's deps.json json file (could also be done using an AssemblyLoadContext and the deps.json file). In this case, the assembly needs to be listed in the deps.json file in order for Core CLR to find it, but since the deps.json file is generated from the assets.json file, it's missing the entry when ExcludeAssets="Runtime" is used.
  4. The design-time entry point loads and executes the user's assembly to add a migration, run tests, scaffold a view, etc.
@bricelam
Copy link

(Also from dotnet/efcore#11437)

This is also broken in .NET Framework projects. In packages.config projects, the assemblies in packages with developmentDependency="true" were copied to the output directory. With <PackageReference>, they're not.

@ajcvickers
Copy link

Note that this is breaking EF Core 1.0, 1.1, 2.0, 2.1 on .NET Core and .NET Framework. Therefore it is breaking the .NET Core SDK for 1.0, 1.1, 2.0, and 2.1.

/cc @Eilon @divega @DamianEdwards for visibility

@jainaashish
Copy link
Contributor Author

Fixed as part of internal bug# https://devdiv.visualstudio.com/DevDiv/_workitems/edit/589635
and commit# NuGet/NuGet.Client@2e21519

@bording
Copy link

bording commented Apr 3, 2018

@jainaashish Since the referenced commit reverted the development dependency support, is there a public followup issue to track adding it back, in whatever form that might occur?

@jainaashish
Copy link
Contributor Author

yeah I've reopened the original issue tracking this work# #4125 and marked for next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants