【发布时间】:2018-11-01 06:48:00
【问题描述】:
我使用 targetframework Netstandard 2.0 创建了一个私有 nuget 包 该包依赖于 EntityFrameworkCore 和 EntityFramework.DbContextScope。
如果我在 .Net Core 项目中使用它,但在 .net Framework 4.6.1 项目中使用它,这非常好。
EntityFramework.DbContextScope 包导致了这些问题。我查看了 nuget 中的源代码并在 project.json 中看到了这个
"frameworks": {
"netstandard1.3": {
"imports": [
],
"dependencies": {
"NETStandard.Library": "1.6.0",
"Microsoft.EntityFrameworkCore.Relational": "1.0.0"
},
"buildOptions": {
"define": [
"EFCore"
]
}
},
"net46": {
"dependencies": {
"EntityFramework": "6.1.3"
},
"buildOptions": {
"define": [
"EF6"
]
},
"frameworkAssemblies": {
"System.Data": "4.0.0.0"
}
},
如果我在 .net framework 4.6.1 项目中安装我的 nuget 包,它也会自动安装 EntityFramework 6,但我使用 EntityFrameworkCore 创建了我的 Nuget 包。
我能否对我的 Nuget 包进行更改,使其始终使用 targetframework netstandard 而不是 net46 安装 EntityFramework.DbContextScope?
编辑:到目前为止,我能完成这项工作的唯一方法是手动编辑 .net framework 4.6.1 项目的 csproj 文件中的提示路径。这可行,但远非理想。
<Reference Include="EntityFramework.DbContextScope, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.DbContextScope.1.0.0\lib\netstandard1.3\EntityFramework.DbContextScope.dll</HintPath>
</Reference>
【问题讨论】: