Skip to content

CLI Commands: Support .NET Framework-only projects #4577

Closed

Description

@bricelam

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.

Currently blocked on dotnet/cli#2126

Known Issues

No executable found matching command "Microsoft.EntityFrameworkCore.Tools.Cli"
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,

Activity

  1. divega commented on Feb 17, 2016

    @divega
    Contributor

    your project must target a .NET Core-compatible framework

    Does that mean they run fine in .NET 4.6 or not?

  2. bricelam commented on Feb 17, 2016

    @bricelam
    ContributorAuthor

    No, the user's assembly needs to be compiled against the .NET Core contracts.

  3. ErikEJ commented on Feb 17, 2016

    @ErikEJ
    Contributor

    But all the commands work in the PMC, I assume?

  4. rowanmiller commented on Feb 17, 2016

    @rowanmiller
    Contributor

    @ErikEJ correct. PMC will light up for xproj in RC2

  5. bricelam commented on Feb 17, 2016

    @bricelam
    ContributorAuthor

    Yes, if you want to target only .NET 4.5.1, using the *.csproj + NuGet commands will work as usual.

  6. rowanmiller commented on Feb 18, 2016

    @rowanmiller
    Contributor

    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.

  7. rowanmiller commented on Feb 22, 2016

    @rowanmiller
    Contributor

    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.

  8. bricelam commented on Mar 25, 2016

    @bricelam
    ContributorAuthor

    Re-opening. It looks like this will happen as part of dotnet/cli#2020

  9. added this to the milestone on Mar 25, 2016
  10. 18 remaining items

  11. natemcmaster commented on May 6, 2016

    @natemcmaster
    Contributor

    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.

  12. natemcmaster commented on May 6, 2016

    @natemcmaster
    Contributor

    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.

    In dotnet-cli

    LibProj/
        project.json 
        TestContext.cs
        - Dependency on Ms.EfCore.Sqlite
        - targets "net451"
    WebApp/
        project.json 
        Startup.cs (provides connection string)
        - References LibProj
        - Dependency on Ms.EfCore.Tools
        - targets "net451"
    

    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.

  13. natemcmaster commented on May 9, 2016

    @natemcmaster
    Contributor

    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

  14. modified the milestones: , 1.0.0 on Oct 15, 2022
  15. added theissue type on Jun 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions