-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Cannot invoke project dependency command on a library #5848
Comments
Updated the original issue description. It looks like I had two bugs conflated, so I redacted the description. The first bug was resolved by deleting muxer. The second bug, however, "Could not resolve coreclr path" error persists. Incidentally, why don't the install scripts delete the muxer for in-place upgrades? |
I took a first stab and this file doesn't exist:
probably because there is no target framework ( |
@schellap and I took a look at this offline. This looks like a design issue, not a bug. "Could not find coreclr" is accurate because there is no coreclr referenced from a library project. This is a common scenario we want to enable for Entity Framework. User's often use EF on a library that is shared between web, desktop, etc. {
"version": "1.0.0-*",
"name": "Contoso.DataAccess",
"dependencies": {
"NETStandard.Library": "1.5.0-*",
"Microsoft.EntityFrameworkCore.Sqlite": "1.0.0-*",
"dotnet-ef": {
"version": "1.0.0-*",
"type": "build"
}
},
"frameworks": {
"netstandard1.5": {
"imports": "portable-net452+win81"
}
},
"tools": {
"dotnet-ef": "1.0.0-*"
}
} How can a user run a dependency tool on this kind of project? cc @DamianEdwards @rowanmiller @piotrpMSFT |
User's can workaround this by invoking the tool a different project, such as a "netcoreapp1.0" web project that references the library. This is unfortunately misleading because means "tools" can still install in a library. Example: to add migrations to "Contoso.DataAccess", you need to invoke dotnet-ef on "Contoso.Web" which references "Contoso.DataAccess". I spoke offline with @rowanmiller and we are okay with this limitation for RC2, so I'm removing the blocking label and milestone. Regardless, it would still be useful to invoke "dependency"-type tools on library projects. This is a general limitation, not just for EF. |
@weshaggard @ericstj @davidfowl @yishaigalatzer for their thoughts on this one. Maybe we can have the library target both netstandard1.x and netcoreapp1.0. The tool would run against the netcoreapp target while we would only ship the netstandard target. Fairly easy to do via command line, but do we want to make this a cleaner experience? What are other options? |
Could work, but I've found this buggy. For example, this project.json has the same error as the original issue above. No runtimeconfig.json is produced for netcoreapp1.0. {
"version": "1.0.0-*",
"dependencies": {
"Microsoft.EntityFrameworkCore.Sqlite": "1.0.0-*"
},
"frameworks": {
"netstandard1.5": {
"imports": [
"portable-net452+win81"
],
"dependencies": {
"NETStandard.Library": "1.5.0-*"
}
},
"netcoreapp1.0": {
"compilationOptions": {
"emitEntryPoint": true
},
"imports": [
"portable-net452+win81"
],
"dependencies": {
"Microsoft.NetCore.App": {
"type": "platform",
"version": "1.0.0-*"
}
}
}
}
} |
Which is the run-able entity here, the TOOL? In that case should the restore be happening for the TOOL's TFM and merging the dependencies of the project as if it were a dependency of the tool? |
I chatted with @ericstj today. He'll put some thought into the model and may have feedback/suggestions. For the time being, however, we need to understand why the project.json above is not producing a deps file/runnable output. |
I pulled https://github.com/natemcmaster/dotnet-sample-tool and was able to get I chatted with @brthor today, and he mentioned a decent idea: If the library isn't already generating the necessary runtimeconfig.json file, maybe the CLI should generate the runtime files for the library as if the project.json was targetting Thoughts? |
I've figured out why I needed to put https://github.com/natemcmaster/dotnet-sample-tool/blob/master/dotnet-my-tool/Program.cs#L21 var framework = project.GetTargetFrameworks().Select(f=>f.FrameworkName).First(); The tool was only running against the first TFM, which in this case was I've pushed some changes to the The CLI behavior is currently by design. In order for dependency tools to be invoked, they need to be invoked on a runnable TFM - namely
There isn't anything the CLI can do in this area in the RC2 timeframe. Pushing to RTM in the hopes we can get support for this scenario from CoreFX. Note: the general scenario is pretty common: you have a tool that wants to load up a library and start invoking code in it. Test runners have this exact same scenario as well. The problem is that you need a runtime to run the app, but there isn't a runtime for the library. And you can't use the tool's runtime because it may not be the correct version that the library needs. |
Has there been any progress on this? There has been a lot of chatter about this limitation, especially because the workarounds are not easy. |
Potentially related to dotnet/efcore#5460 |
@natemcmaster I put a different solution for dotnet/efcore#5460 here: dotnet/efcore#5460 (comment) cc/ @Villason |
Ok
`System.TypeLoadException
Could not load type 'ApplicationDataModel.Models.CarsAd' from assembly 'ApplicationDataModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.`
What ! build again and again using visual studio and nothing
and this is weird as i check the output and visual studio is using dotnet.exe !!! so why the assembly only updated when i used dotnet build via package manager. build output:
my ApplicationDataModel Project.json:
dotnet -- info
BTW, the same "Converted Class Library Project" working fine in another two class library projects (web jobs) in the same solution. Sorry for English mistakes |
@ahmedanis03 can you report this issue to https://github.com/aspnet/EntityFramework instead? Your error is different from the issue this bug was opened to track. |
We've had a few conversations internally about this. The most recent thinking is that the ASP.NET tooling that needs to load and execute user code can use an assembly load context to load the user's library into the tool process, rather than launching a new process. Using a load context hasn't been proven to work yet, and it will likely require some tweaks to the build system to make sure a load context on a class library can get the right dependencies. |
Glad I found this issue here, very useful. Sorry for the annoying question, but is there a ballpark ETA on this one - just so I can make some plans this end? (An order of magnitude is good enough for me! - 1d/1w/1m/1q/1y) |
Closing. In aspnet, we refactored our tools a long time ago to not use ProjectDependenciesCommandFactory. Also, this doesn't seem like something we could ever fix in the CLI: netstandard libraries projects are not executable. |
Update: the error is only on libraries, not standalone.
It looks like dotnet/cli#2617 broke PackagedCommandSpecFactory in tools on standalone apps.Steps to reproduce
Create a tool that invokes tries to execute a dependency command where projectContext is a netstandard library.
Repro project: https://github.com/natemcmaster/dotnet-sample-tool/tree/issue2645.
Expected behavior
ProjectDependenciesCommandFactory should create and execute a command on the netstandard library.
Actual behavior
On a library project
Environment data
Microsoft.DotNet.Cli.Utils/1.0.0-rc2-002476
dotnet --info
output:Fails on windows and linux.
Trace: corehost_trace.log.txt
cc @schellap @piotrpMSFT
The text was updated successfully, but these errors were encountered: