You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CLI Commands: Support .NET Framework-only projects #4577
Currently, in order to use the .NET Core CLI EF commands, your project must target a .NET Core-compatible framework. We could remove this requirement by starting a new net451 process to execute the commands in this case.
System.IO.FileNotFoundException: Could not load file or assembly 'StartupProj' or one of its dependencies. The system cannot find the file specified. File name: 'StartupProj'
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint,
For folks using VS, the primary way to invoke these commands is Package Manager Console (which will be enabled in RC2). That means for the developer workflow, this would only be needed for someone developing against Full .NET and wanting to use the command line tools. This seems like it will be a small set of folks.
One thing we didn't consider in triage though is that this could be very useful for build/deployment integration.
Discussed and decided that our general purpose CLI that runs on assemblies (#646) rather than our .NET CLI specific commands is the thing that will be best suited to build/deployment/etc. Given that, closing this out but we can reconsider if we see customers wanting this in real applications.
Known issue: if a user is trying to use dotnet-ef on a net451 project where "buildOptions" > "emitEntryPoint": false, dotnet-ef cannot execute. It tries to dispatch to a command inside bin/Debug/net451/win7-x64/Microsoft.EntityframeworkCore.Tools.Cli.exe, but for class libraries, the command is in bin/Debug/net451/Microsoft.EntityframeworkCore.Tools.Cli.exe.
Second issue: dotnet-ef cannot load the startup assembly in desktop .NET when executing on a different project. This was a design oversight on our part. Here is the issue:
In PowerShell
LibProj/
LibProj.csproj
TestContext.cs
- Dependency on Ms.EfCore.Sqlite
WebApp/
WebApp.csproj
Startup.cs (provides connection string)
- References LibProj
- Dependency on Ms.EfCore.Tools
Add-Migration Init -Project LibProj -StartupProject WebApp
The powershell will load WebApp.dll, using the app domain base path as WebApp/bin/Debug/. Because WebApp references LibProj, all assemblies need to run migrations are in WebApp/bin/Debug/ and can be reflected on.
C:\LibProj\ > dotnet ef migrations add --startup-project ../WebApp
The CLI invokes LibProj/bin/Debug/net451/Microsoft.EntityFrameworkCore.Tools.Cli.exe which means the app domain base directory does not include WebApp.dll. When we try to load WebApp.Startup, .NET can't find the right assembly becauase it isn't availalbe in this app domain. Instead, Microsoft.EntityFrameworkCore.Tools.Cli needs to setup a new app domain pointed at WebApp/bin/Debug/net451 in order to load Startup.
Activity
divega commentedon Feb 17, 2016
Does that mean they run fine in .NET 4.6 or not?
bricelam commentedon Feb 17, 2016
No, the user's assembly needs to be compiled against the .NET Core contracts.
ErikEJ commentedon Feb 17, 2016
But all the commands work in the PMC, I assume?
rowanmiller commentedon Feb 17, 2016
@ErikEJ correct. PMC will light up for xproj in RC2
bricelam commentedon Feb 17, 2016
Yes, if you want to target only .NET 4.5.1, using the *.csproj + NuGet commands will work as usual.
rowanmiller commentedon Feb 18, 2016
For folks using VS, the primary way to invoke these commands is Package Manager Console (which will be enabled in RC2). That means for the developer workflow, this would only be needed for someone developing against Full .NET and wanting to use the command line tools. This seems like it will be a small set of folks.
One thing we didn't consider in triage though is that this could be very useful for build/deployment integration.
rowanmiller commentedon Feb 22, 2016
Discussed and decided that our general purpose CLI that runs on assemblies (#646) rather than our .NET CLI specific commands is the thing that will be best suited to build/deployment/etc. Given that, closing this out but we can reconsider if we see customers wanting this in real applications.
bricelam commentedon Mar 25, 2016
Re-opening. It looks like this will happen as part of dotnet/cli#2020
18 remaining items
natemcmaster commentedon May 6, 2016
Known issue: if a user is trying to use dotnet-ef on a net451 project where "buildOptions" > "emitEntryPoint": false, dotnet-ef cannot execute. It tries to dispatch to a command inside
bin/Debug/net451/win7-x64/Microsoft.EntityframeworkCore.Tools.Cli.exe, but for class libraries, the command is inbin/Debug/net451/Microsoft.EntityframeworkCore.Tools.Cli.exe.natemcmaster commentedon May 6, 2016
Blocked: https://github.com/dotnet/cli/issues/2919
natemcmaster commentedon May 6, 2016
Second issue: dotnet-ef cannot load the startup assembly in desktop .NET when executing on a different project. This was a design oversight on our part. Here is the issue:
In PowerShell
Add-Migration Init -Project LibProj -StartupProject WebAppThe powershell will load
WebApp.dll, using the app domain base path asWebApp/bin/Debug/. Because WebApp references LibProj, all assemblies need to run migrations are inWebApp/bin/Debug/and can be reflected on.In dotnet-cli
C:\LibProj\ > dotnet ef migrations add --startup-project ../WebAppThe CLI invokes
LibProj/bin/Debug/net451/Microsoft.EntityFrameworkCore.Tools.Cli.exewhich means the app domain base directory does not include WebApp.dll. When we try to load WebApp.Startup, .NET can't find the right assembly becauase it isn't availalbe in this app domain. Instead, Microsoft.EntityFrameworkCore.Tools.Cli needs to setup a new app domain pointed atWebApp/bin/Debug/net451in order to load Startup.natemcmaster commentedon May 9, 2016
Base support for CLI commands on desktop is added for RC2. Remaining issues are tracked else where.
See #5311 and https://github.com/dotnet/cli/issues/2645