Search code examples
c#nugetdnx.net-core

can nuget packages compiled against .net4.5 be referenced by dnxcore50


I'm compiling an application that targets the dnxcore50 only.

I'm attempting to reference a nuget package that I know works fine when run against dnx451. When I do dnx . run I get:

System.InvalidOperationException: Failed to resolve the following dependencies for target framework 'DNXCore,Version=v5.0':

it also suggests a dnu restore but the package is there

It does not work for this package clearly so under what circumstances will it (if any) ?
In order for it to work must the package manager build a version compiled against dnxcore50?

update

this chart makes things a bit clearer (copied from here)

enter image description here


Solution

  • No. dnxcore50 indicates you're running on DNX on top of .NET Core. The only assemblies you can load in .NET Core are those that target a compatible profile, in this case e.g. dnxcore50, dotnet, or one of the compatible portable profiles.

    If you have an assembly compiled against the full .NET Framework (via net45, net451, etc.), it won't run when on .NET Core as the same APIs aren't available.