这种情况可能很奇怪。但我想使用Nuget将现有的.NET 4.5.2类库引用到新的.Net Standard 1.6类库中。我根本无法在Nuget包存储中看到.Net 4.5.2类库。
我不想将任何现有项目迁移到.Net Core,但希望在.Net核心项目中使用它们。
有可能实现这一目标吗?或者我正在努力实现一些不是.Net Core目的的东西。
我的project.json如下。
{
"version": "1.0.0-*",
"dependencies": {
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0",
"NETStandard.Library": "1.6.0",
"AutoMapper": "5.0.2",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
"Microsoft.VisualStudio.clrdbg": "14.0.25520-preview-3139256"
},
"tools" : {
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview2-final",
"imports": [
"portable-net45+win8+dnxcore50",
"portable-net45+win8"
]
}
},
"frameworks": {
"netstandard1.6": {
"imports": [ "dnxcore50", "net452" ]
}
}
}
更新:
我在net452
下添加了frameworks
部分。然后我得到无法解决已安装的几个软件包的错误。 PFA截图。
无论如何,我可以强制这样做。
答案 0 :(得分:2)
您在框架导入部分中错过了Net45导入。如果它是一个可运行的项目,那么您将需要将Microsoft.NETCore.App添加到您的依赖项并导入必要的框架以使其工作
{
"version": "1.0.0-*",
"dependencies": {
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0",
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"AutoMapper": "5.0.2",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
"Microsoft.VisualStudio.clrdbg": "14.0.25520-preview-3139256"
},
"tools" : {
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview2-final",
"imports": [
"portable-net45+win8+dnxcore50",
"portable-net45+win8"
]
}
},
"frameworks": {
"netcoreapp1.1": {
"imports": [
"portable-net45+wp80+win8+wpa81+dnxcore50",
"dnxcore50",
"net452"
]
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
}
但是,如果您正在使用PCL,那么您需要使用netstandard框架并导入必要的框架以便PCL构建。
{
"version": "1.0.0-*",
"dependencies": {
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0",
"NETStandard.Library": "1.6.0",
"AutoMapper": "5.0.2",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
"Microsoft.VisualStudio.clrdbg": "14.0.25520-preview-3139256"
},
"tools" : {
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview2-final",
"imports": [
"portable-net45+win8+dnxcore50",
"portable-net45+win8"
]
}
},
"frameworks": {
"netstandard1.6": {
"imports": [
"portable-net45+wp80+win8+wpa81+dnxcore50",
"dnxcore50",
"net452"
]
}
}
}