I have two projects: one project is built on .NET Core and the other one is built on normal .NET Framework 4.5.2.
I want to know how I can use my .NET Core cass library in my .NET Console Application.
Here is my project.json:
{
"version": "1.0.0-*",
"dependencies": {
"NETStandard.Library": "1.6.0",
"NLog.Web.AspNetCore": "4.3.0",
"System.Xml.XmlSerializer": "4.0.11"
},
"frameworks": {
"netstandard1.6": {
"imports": "dnxcore50"
},
"net452": {}
}
}
I tried to include the project as a normal reference. But after re-building the solution the Console Application still doesn't get the .NET Core library as a reference.
Visual Studio 2017 can do this natively; Visual Studio 2015 cannot (as of Update 3). A lot of these tooling bugs and issues are being fixed and finalized with the stable version of the .NET Core tooling, expected with VS 2017.
There are two workarounds you can use today, if you are still using VS 2015:
Use dotnet pack
to produce a NuGet package for the class library. Since you target net452
in your project.json, it will be compatible with a .NET Framework 4.5.2 project. You can host it on a local feed and install it in your console application project.
Manually reference the DLL that's produced when you compile the library. It should be at bin/net452/YourLibrary.dll
. This isn't a great solution because it's brittle and can break easily.