.Net Core and project.lock.json

2019-09-07 00:14发布

I have a VS2015 (Update 3) solution with several projects: one ASP.Net Core website and several .Net Core class libraries. Every time I add a reference from one project to another, I get reference error on one or more projects:

enter image description here

If I look at the Error List as the error message on References suggests, I see the following error for every project whose references broke: "An item with the same key has already been added. Key: Ansarada.ServicesApi.ApplicationServices".

To fix the issue, I delete project.lock.json for each broken project. VS straight away regenerates it, and then the project is fixed. This is obviously very annoying. Any solutions to this? Thanks.


Addition to the original question. I have been asked to provide my project.json files. Here are files for 3 projects (there are more in the whole solution):

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

标签: .net-core
0条回答
登录 后发表回答