.Net Core和project.lock.json

时间:2017-02-21 03:05:55

标签: .net-core

我有一个VS2015(Update 3)解决方案,包含几个项目:一个ASP.Net Core网站和几个.Net Core类库。每次我将一个项目的引用添加到另一个项目时,我会在一个或多个项目中得到引用错误:

enter image description here

如果我查看错误列表作为参考建议的错误消息,我看到每个参考项目破坏的项目出现以下错误:“已添加具有相同密钥的项目。密钥: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%"]
    }
}

Ansarada.ServicesApi.ApplicationServices project.json:

{
    "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-*"
   }
}

Ansarada.ServicesApi.Repositories project.json:

{
    "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"
   }
}

0 个答案:

没有答案