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

Powershell Tools 1.1.0-preview4 fails when target >=net452 #7146

Closed
farlop opened this issue Nov 28, 2016 · 8 comments
Closed

Powershell Tools 1.1.0-preview4 fails when target >=net452 #7146

farlop opened this issue Nov 28, 2016 · 8 comments

Comments

@farlop
Copy link

farlop commented Nov 28, 2016

Steps to reproduce

  • Create a Web API site.
  • In project.json, set 'frameworks' to just 'net462' and update all packages to version '1.1.0'
"dependencies": {    
    "Microsoft.AspNetCore.Mvc": "1.1.0",
    "Microsoft.AspNetCore.Routing": "1.1.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
    "Microsoft.Extensions.Configuration.Json": "1.1.0",
    "Microsoft.Extensions.Logging": "1.1.0",
    "Microsoft.Extensions.Logging.Console": "1.1.0",
    "Microsoft.Extensions.Logging.Debug": "1.1.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0"
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final"
  },

  "frameworks": {    
    "net462": {}
  },
...
  • Create a new .NET Core library.
  • In project.json, set 'frameworks' to just 'net462' and install EFCore 1.1 and Tools
{
  "version": "1.0.0-*",

  "dependencies": {
    "Microsoft.EntityFrameworkCore.Design": "1.1.0",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
    "Microsoft.EntityFrameworkCore.SqlServer.Design": "1.1.0",
    "Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final"    
  },
  "tools": {
    "Microsoft.EntityFrameworkCore.Tools.DotNet": "1.1.0-preview4-final"    
  },

  "frameworks": {
    "net462": {}
  }
}
  • Add a reference in web api project to the library.
  • In Package Manager, set the project to the library and try the Scaffold-Db command
    Scaffold-DbContext -Connection "server=<server>;Database=<dbname>;Integrated Security=true" Microsoft.EntityFrameworkCore.SqlServer -Verbose

The issue

Code is not generated and the error shown is:

Build started...
Build succeeded.
Could not find assembly '[...]\.\bin\Debug\net462\win7-x64\<libraryname>.exe'.

Further technical details

EF Core version: 1.1
Operating system: Windows 10 14393.447
Visual Studio version: VS2015 Update 3 14.0.25431.01
NuGet Package Manager: 3.5.0.1996 (beta)

@micdenny
Copy link
Contributor

I had the same problem, but when adding a migration instead. In fact every PS command I tried from Package Manager Console ends up with:

Could not find assembly 'C:\Users\micde\Documents\Visual Studio 2015\Projects\EFCore.AspNetCore.Migration\src\EFCore.AspNetCore.Migration\.\bin\Debug\net452\win7-x64\EFCore.AspNetCore.Migration.Data.exe'.

It seems to use the Project name instead of StartupProject name when searching for the entry point.

I suggest to rename the issue in Powershell Tools 1.1.0-preview4 fails when target >=net452 what do you think @farlop?

I don't know if it is connected, but #7071 has a similar problem, but I don't think that workaround will it work even here.

@farlop
Copy link
Author

farlop commented Nov 30, 2016

I'm agree with you, as it seems something generally related to the tools itself. I'm going to try the walkarounds proposed in #7071 using preview3 and las nightly of preview4 and update with results.

@farlop farlop changed the title Scaffolding to another project fails when target framework is "net462" Powershell Tools 1.1.0-preview4 fails when target >=net452 Nov 30, 2016
@farlop
Copy link
Author

farlop commented Nov 30, 2016

You were right. Trying to use 1.0.0-preview3-final trows the following error:

Could not invoke this command on the startup project 'ScaffoldTestEF'.
Entity Framework Core does not support commands on class library projects in ASP.NET Core and .NET Core applications.

And using the latests nightly '1.2.0-preview4-22845' gives the same error as using '1.1.0-preview4-final'...

@micdenny
Copy link
Contributor

Could not invoke this command on the startup project 'ScaffoldTestEF'.

This is another problem they are fixing on netcore CLI, you have to set the StartupProject to point an application, that means a library that emit the entry point "emitEntryPoint": true

You should try with something like this:

Add-Migration CreateDatabase -StartupProject EFCore.AspNetCore.ProdMigration -Project EFCore.AspNetCore.ProdMigration.Data

where EFCore.AspNetCore.ProdMigration.Data is the class library set to compile to net452 and EFCore.AspNetCore.ProdMigration is a netcore asp.net or console application.

BTW I've tested the script above using the version 1.2.0-preview4-22845 and I have the same problem:

Could not find assembly 'C:\Users\micde\Documents\Visual Studio 2015\Projects\EFCore.AspNetCore.ProdMigration\src\EFCore.AspNetCore.ProdMigration.\bin\Debug\net452\win7-x64\EFCore.AspNetCore.ProdMigration.Data.exe'.

I've created a gist with the simple app to reproduce the problem:

https://gist.github.com/micdenny/b23fac112d8607b998e63e3b3adfa402

@rowanmiller
Copy link
Contributor

There are a lot of issues with the tooling at the moment (they mostly stem from the complexity of trying to support project.json/xproj and the new MSBuild based tooling - neither of which is a stable release themselves).

Two things to try.

  • Try using the dotnet ef commands at a command prompt instead (you already have them correctly registered in the project.json that you posted)
  • Roll back the tooling to 1.0.0-preview3-final. You can leave the runtime at 1.1 as the tools are compatible with any runtime version.

I realize this is a big mess, so we are just trying to find workarounds to unblock folks while we stabilize the tooling for the next release.

@micdenny
Copy link
Contributor

micdenny commented Dec 1, 2016

Thank you @rowanmiller and your team for the great effort you put on this project. This is a tool in preview so I agree that we have to find workarounds and wait for the next release (msbuild based).

Try using the dotnet ef commands at a command prompt instead (you already have them correctly registered in the project.json that you posted)

with the dotnet ef command it works, but it is mandatory to reference from the startup project the data library that is quite a common use case.

Roll back the tooling to 1.0.0-preview3-final. You can leave the runtime at 1.1 as the tools are compatible with any runtime version.

the rollback to 1.0.0-preview3-final just works fine for both dotnet ef command and package manager console.

Another workaround is to emit the entrypoint for the data class library, in that way the 1.2.0-preview4-22845 works for all the tools (dotnet & package manager console), instead the 1.1.0-preview4-final works only on package manager console (from dotnet cli returns Unrecognized option '--config').

@farlop
Copy link
Author

farlop commented Dec 1, 2016

Thank you @micdenny and @rowanmiller for all the workarounds. I've been able to scaffold the database using 1.0.0-preview3-final using the -StartupProject option.

@rowanmiller
Copy link
Contributor

Closing as we have a workaround... these issues are being resolved in future releases of the tools.

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants