Using net451 libraries in an ASP.NET Core (RC2) application

I am trying to upgrade ASP.NET 5 RC1 projects to ASP.NET Core RC2 projects. I'm having some problems because I use libraries that do not yet support .NET Core, so I have to work in a complete structure. This works fine in RC1, but I can't find the right way to achieve this in RC2.

I have one class library that can repair packages and build them correctly. And I have a test project referencing a class library. When I try to create a test project, I get the following errors:

> dotnet build Project TenantService (.NETFramework,Version=v4.5.1) was previously compiled. Skipping compilation. Project TenantServiceTests (.NETCoreApp,Version=v1.0) will be compiled because expected outputs are missing Compiling TenantServiceTests for .NETCoreApp,Version=v1.0 C:\projects\TenantService\test\TenantServiceTests\project.json(25,23): error NU1001: The dependency mscorlib could not be resolved. C:\projects\TenantService\test\TenantServiceTests\project.json(9,31): error NU1001: The dependency mscorlib could not be resolved. C:\projects\TenantService\test\TenantServiceTests\project.json(25,23): error NU1001: The dependency mscorlib could not be resolved. C:\projects\TenantService\test\TenantServiceTests\project.json(9,31): error NU1001: The dependency mscorlib could not be resolved. C:\projects\TenantService\test\TenantServiceTests\project.json(26,21): error NU1001: The dependency System could not be resolved. C:\projects\TenantService\test\TenantServiceTests\project.json(9,31): error NU1001: The dependency System could not be resolved. C:\projects\TenantService\test\TenantServiceTests\project.json(26,21): error NU1001: The dependency System could not be resolved. C:\projects\TenantService\test\TenantServiceTests\project.json(9,31): error NU1001: The dependency System could not be resolved. C:\projects\TenantService\test\TenantServiceTests\project.json(27,26): error NU1001: The dependency System.Core could not be resolved. C:\projects\TenantService\test\TenantServiceTests\project.json(9,31): error NU1001: The dependency System.Core could not be resolved. C:\projects\TenantService\test\TenantServiceTests\project.json(27,26): error NU1001: The dependency System.Core could not be resolved. C:\projects\TenantService\test\TenantServiceTests\project.json(9,31): error NU1001: The dependency System.Core could not be resolved. C:\projects\TenantService\test\TenantServiceTests\project.json(9,31): error NU1001: The dependency Microsoft.CSharp could not be resolved. 

The project.json files for these two projects are as follows:

SIC \ TenantService \ project.json

 { "version": "1.0.0-*", "dependencies": { "NETStandard.Library": "1.5.0-rc2-24027", "Microsoft.Extensions.Options": "1.0.0-rc2-final", "Newtonsoft.Json": "8.0.4-beta1", "MongoDB.Driver": "2.2.4", "StackExchange.Redis": "1.1.603" }, "frameworks": { "net451": {} } } 

test \ TenantServiceTests \ project.json

 { "version": "1.0.0-*", "testrunner": "xunit", "description": "TenantServiceTests Class Library", "authors": [ "Henning" ], "dependencies": { "xunit": "2.1.0", "TenantService": "1.0.0-*", "dotnet-test-xunit": "1.0.0-rc2-build10015" }, "frameworks": { "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { "type": "platform", "version": "1.0.0-rc2-3002702" } }, "imports": [ "net451" ] } } } 

How should I properly configure this to use the net451 libraries in my application?

+6
source share
1 answer

Mscorlib dependency cannot be resolved

I ran into this problem yesterday. The problem is that project.json for the test project targets netcoreapp1.0 . Instead, you can target the net451 infrastructure as a service that you are testing and that should "just work."

 { "version": "1.0.0-*", "testrunner": "xunit", "description": "TenantServiceTests Class Library", "authors": [ "Henning" ], "dependencies": { "xunit": "2.1.0", "TenantService": "1.0.0-*", "dotnet-test-xunit": "1.0.0-rc2-build10015" }, "frameworks": { "net451": { } } } 

You can learn more about this from Migration from ASP.NET 5 RC1 to ASP.NET Core . Another great resource is the delimited file on corefx repo , which details the .NET Platform Standard .

+2
source

All Articles