.net core .Net核心和project.lock.json
我有一个VS2015(更新3)解决方案和几个项目:一个ASP.Net核心网站和几个.Net核心类库。每次我将引用从一个项目添加到另一个项目时,一个或多个项目上都会出现引用错误: 如果我按照引用上的错误消息所示查看错误列表,我会看到每个引用中断的项目都会出现以下错误:“已经添加了具有相同键的项。键:Ansarada.ServicesApi.ApplicationServices” 为了解决这个问题,我删除了每个损坏项目的project.lock.json。VS立即重新生成它,然后项目被修复。这显然很烦人。有什么解决办法吗?谢谢.net core .Net核心和project.lock.json,.net-core,.net Core,我有一个VS2015(更新3)解决方案和几个项目:一个ASP.Net核心网站和几个.Net核心类库。每次我将引用从一个项目添加到另一个项目时,一个或多个项目上都会出现引用错误: 如果我按照引用上的错误消息所示查看错误列表,我会看到每个引用中断的项目都会出现以下错误:“已经添加了具有相同键的项。键:Ansarada.ServicesApi.ApplicationServices” 为了解决这个问题,我删除了每个损坏项目的project.lock.json。VS立即重新生成它,然后项目被修复。这显
对原问题的补充。我被要求提供project.json文件。以下是3个项目的文件(整个解决方案中还有更多): Ansarada.ServicesApi.ServiceHost project.json:
{
"dependencies": {
"Ansarada.ServicesApi.Settings": "1.0.0-*",
"Ansarada.ServicesApi.DependencyInjection": "1.0.0-*",
"Ansarada.ServicesApi.Middleware": "1.0.0-*",
"Autofac.Extensions.DependencyInjection": "4.0.0",
"Microsoft.AspNetCore.Routing": "1.1.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
"Microsoft.AspNetCore.Mvc": "1.1.1",
"Ansarada.ServicesApi.ApplicationServices": "1.0.0-*",
"Ansarada.ServicesApi.Enums": "1.0.0-*"
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"net462": {}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
"publishOptions": {
"include": [
"wwwroot",
"**/*.cshtml",
"appsettings*.json",
"web.config"
]
},
"scripts": {
"postpublish": ["dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"]
}
}
{
"version": "1.0.0-*",
"frameworks": {
"net462": {}
},
"dependencies": {
"Ansarada.ServicesApi.Enums": "1.0.0-*",
"Ansarada.ServicesApi.Proxies": "1.0.0-*",
"Ansarada.ServicesApi.Repositories": "1.0.0-*"
}
}
{
"version": "1.0.0-*",
"frameworks": {
"net462": {
"frameworkAssemblies": {
"System.Transactions": "4.0.0.0"
}
}
},
"dependencies": {
"Ansarada.ServicesApi.Enums": "1.0.0-*",
"Ansarada.ServicesApi.Settings": "1.0.0-*",
"Dapper": "1.50.2"
}
}
Ansarada.ServicesApi.ApplicationServices项目.json:
{
"dependencies": {
"Ansarada.ServicesApi.Settings": "1.0.0-*",
"Ansarada.ServicesApi.DependencyInjection": "1.0.0-*",
"Ansarada.ServicesApi.Middleware": "1.0.0-*",
"Autofac.Extensions.DependencyInjection": "4.0.0",
"Microsoft.AspNetCore.Routing": "1.1.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
"Microsoft.AspNetCore.Mvc": "1.1.1",
"Ansarada.ServicesApi.ApplicationServices": "1.0.0-*",
"Ansarada.ServicesApi.Enums": "1.0.0-*"
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"net462": {}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
"publishOptions": {
"include": [
"wwwroot",
"**/*.cshtml",
"appsettings*.json",
"web.config"
]
},
"scripts": {
"postpublish": ["dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"]
}
}
{
"version": "1.0.0-*",
"frameworks": {
"net462": {}
},
"dependencies": {
"Ansarada.ServicesApi.Enums": "1.0.0-*",
"Ansarada.ServicesApi.Proxies": "1.0.0-*",
"Ansarada.ServicesApi.Repositories": "1.0.0-*"
}
}
{
"version": "1.0.0-*",
"frameworks": {
"net462": {
"frameworkAssemblies": {
"System.Transactions": "4.0.0.0"
}
}
},
"dependencies": {
"Ansarada.ServicesApi.Enums": "1.0.0-*",
"Ansarada.ServicesApi.Settings": "1.0.0-*",
"Dapper": "1.50.2"
}
}
Ansarada.ServicesApi.Repositories project.json:
{
"dependencies": {
"Ansarada.ServicesApi.Settings": "1.0.0-*",
"Ansarada.ServicesApi.DependencyInjection": "1.0.0-*",
"Ansarada.ServicesApi.Middleware": "1.0.0-*",
"Autofac.Extensions.DependencyInjection": "4.0.0",
"Microsoft.AspNetCore.Routing": "1.1.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
"Microsoft.AspNetCore.Mvc": "1.1.1",
"Ansarada.ServicesApi.ApplicationServices": "1.0.0-*",
"Ansarada.ServicesApi.Enums": "1.0.0-*"
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"net462": {}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
"publishOptions": {
"include": [
"wwwroot",
"**/*.cshtml",
"appsettings*.json",
"web.config"
]
},
"scripts": {
"postpublish": ["dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"]
}
}
{
"version": "1.0.0-*",
"frameworks": {
"net462": {}
},
"dependencies": {
"Ansarada.ServicesApi.Enums": "1.0.0-*",
"Ansarada.ServicesApi.Proxies": "1.0.0-*",
"Ansarada.ServicesApi.Repositories": "1.0.0-*"
}
}
{
"version": "1.0.0-*",
"frameworks": {
"net462": {
"frameworkAssemblies": {
"System.Transactions": "4.0.0.0"
}
}
},
"dependencies": {
"Ansarada.ServicesApi.Enums": "1.0.0-*",
"Ansarada.ServicesApi.Settings": "1.0.0-*",
"Dapper": "1.50.2"
}
}
尝试以下步骤-1。删除
项目.lock.json
,2。运行dotnet还原--无缓存
,3。运行dotnet build
。从下一次开始,它应该在VS.Hi@Sanket中构建良好。我对解决方案中的每个项目都做了上述操作,但不幸的是,这没有任何区别。请向我们展示您的project.json
文件:)@eastroll我已将它们添加到原始问题中