Reputation: 933
We are in process of building a new WebApi. We started out with using .Net Core Rc1 before summer holidays - and now, with .Net Core being 1.0 I would like to update.
But I run into some issues - which I can't figure out if I can solve?
The challenge is that I need to reference some .Net 4.5.1 x86 assemblies.
This means I need to use a moniker that allows use of .Net 4.5.1 - and if I need both worlds, as I understand it - only netstandard16 is available. (https://learn.microsoft.com/da-dk/dotnet/articles/standard/library)
But then I run into the issue that .Net 4.6.3 (or vNext in the above link) is not available yet.
If I reference netstandard15 - then AspNetCore libraries won't work.
If I reference netstandard16 - then I get the following errors
error : Can not find runtime target for framework '.NETStandard,Version=v1.6' compatible with one of the target runtimes: 'win10-x64, win81-x64, win8-x64, win7-x64'. Possible causes:
error : 1. The project has not been restored or restore failed - run `dotnet restore`
error : 2. The project does not list one of 'win10-x64, win81-x64, win8-x64, win7-x64' in the 'runtimes' section.
error : 3. You may be trying to publish a library, which is not supported. Use `dotnet pack` to distribute libraries.
Is it at all possible with current available bits to do the following
Is anyone able to help me out here?
EDIT: The project.json (in two versions)
From RC1
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"AutoMapper": "4.2.1",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
"Swashbuckle.SwaggerUi": "6.0.0-rc1-final",
"Swashbuckle.SwaggerGen": "6.0.0-rc1-final"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
"frameworks": {
"dnx451": {
"dependencies": {
"BaseClasses": "1.0.0-*",
"DatabaseAccessCS": "1.0.0-*",
"BusinessLogic": "1.0.0-*",
"StandardFunctionsCS": "1.0.0-*"
},
"frameworkAssemblies": {
"System.configuration": "4.0.0.0"
}
}
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
]
}
The attempt on final 1.0 that came closest to working
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {
"AutoMapper": "5.1.1",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Mvc.Core": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Swashbuckle.SwaggerGen": "6.0.0-beta902",
"Swashbuckle.SwaggerUi": "6.0.0-beta902"
},
"frameworks": {
"netstandard16": {
"dependencies": {
"BaseClasses": {
"target": "project"
},
"DatabaseAccessCS": {
"target": "project"
},
"BusinessLogic": {
"target": "project"
},
"StandardFunctionsCS": {
"target": "project"
}
}
}
}
}
Final json that works
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true,
"platform": "x86"
},
"runtimes": {
"win": ["win7-x86", "win8-x86", "win10-x86"]
},
"dependencies": {
"AutoMapper": "5.1.1",
"LogiholdBusinessObjects": "5.5.0",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Mvc.Core": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Swashbuckle.SwaggerGen": "6.0.0-beta902",
"Swashbuckle.SwaggerUi": "6.0.0-beta902"
},
"frameworks": {
"net451": {
"frameworkAssemblies": {
"System.Configuration": "4.0.0.0"
}
}
}
}
Upvotes: 0
Views: 182
Reputation: 46531
If you want a .NET Core appliction, you should use the netcoreapp1.0
target framework. You probably won't be able to reference the .NET 4.5.1 library in the .NET Core app.
You could also target a desktop (full) .NET Framework like this:
"frameworks": {
"net451": { }
}
Now you can use .NET 4.5.1 library but your application won't run on the .NET Core runtime anymore.
You could also target a higher version of .NET, just like `net461 for example.
Upvotes: 1