I'm been investigating options available to me for referencing existing .NET Framework 4.6 libraries in new .NET Core App projects.
As a proof of concept I've built a very simple .NET Framework 4.6 library, published it as a NuGet package and included it in a simple .NET Core Web app.
As of now the only way I seem to be able to get the project building and running is to remove the Microsoft.NETCore.App reference from the project.json dependencies block and replace the netcoreapp1.0 section from the frameworks property with a net461 block.
Full project.json below:
{
"dependencies": {
/*"Microsoft.NETCore.App": {
"version": "1.0.0",
"type": "platform"
},*/
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"FileIOLibrary_1_0_0_0": "1.0.0"
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
},
/*"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8",
"net461"
]
}
},*/
"frameworks": {
"net461": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
"publishOptions": {
"include": [
"wwwroot",
"web.config"
]
},
"scripts": {
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
This basically means that all references are .NET Framework 4.6 libraries.
Anyway I've a few questions regarding other options available to me:
- Is it possible to specify that only my imported library should be targeted towards the .NET 4.6 Framework and all other references should use .NET core? If so this would mean I could add the the Microsoft.NETCore.App reference back into the project.
- If the above is not possible can I rebuild my library as a compatible .NET standard library (I believe version 1.6 is compatible between Framework 4.6 and Core 1.0.0)? I've been unable to see an option in Visual Studio to allow me to build libraries against the .NET Standard so would appreciate some pointers in this direction if its an option.