ASP .NET 5 MVC 6 beta 7 升级:"Multiple assemblies with equivalent identity" 问题

ASP .NET 5 MVC 6 beta 7 upgrade : "Multiple assemblies with equivalent identity" issue

目前正在尝试从 ASP .NET 5 MVC 6 的 beta 6 升级到 beta 7。 我按照此处详述的步骤进行操作: 但我仍然遇到程序集问题:

Multiple assemblies with equivalent identity have been imported: '<in-memory-assembly>' and '<in-memory-assembly>'. Remove one of the duplicate references.

This blog 给出了一些解决问题的线索,但不幸的是与我的项目情况不符。

我知道它链接到 project.json 中的软件包列表。一些解决方案建议 Microsoft.Framework.Runtime.Abstractions 但我又一次没有在我的列表中。

我的项目有几个部分有时会相互引用。其中两个出现装配问题,我认为它是相关的,因为每个错误出现 8 次。

以下是两者的 project.json :

{
    "webroot": "wwwroot",
    "version": "1.0.0-*",
    "dependencies": {
        "EntityFramework.SqlServer": "7.0.0-beta7",
        "EntityFramework.Commands": "7.0.0-beta7",
        "EntityFramework.Core": "7.0.0-beta7",
        "Microsoft.AspNet.Mvc": "6.0.0-beta7",
        "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta7",
        "Microsoft.AspNet.Diagnostics": "1.0.0-beta7",
        "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta7",
        "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta7",
        "Microsoft.AspNet.Server.IIS": "1.0.0-beta7",
        "Microsoft.AspNet.Loader.IIS": "1.0.0-beta7",
        "Microsoft.AspNet.Server.WebListener": "1.0.0-beta7",
        "Microsoft.AspNet.StaticFiles": "1.0.0-beta7",
        "Microsoft.Framework.Configuration": "1.0.0-beta7",
        "Microsoft.Framework.Configuration.Json": "1.0.0-beta7",
        "Microsoft.Framework.CodeGenerators.Mvc": "1.0.0-beta5",
        "Microsoft.Framework.Logging": "1.0.0-beta7",
        "Microsoft.Framework.Logging.Console": "1.0.0-beta7",
        "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta7",
        "SSI.Domain": "",
        "SSI.Service": "",
        "log4net": "2.0.3",
        "jQuery.UI.Themes.smoothness": "1.8.9",
        "SSI.WordDocumentGenerator.Client": "1.0.0-*"
    },
    "commands": {
        "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000",
        "gen": "Microsoft.Framework.CodeGeneration",
        "ef": "EntityFramework.Commands"
    },
    "frameworks": {
        "dnx451": {
            "frameworkAssemblies": {
                "System.DirectoryServices": {
                    "version": "",
                    "type": "build"
                },
                "System.DirectoryServices.AccountManagement": {
                    "version": "4.0.0.0",
                    "type": "build"
                }
            }
        }
    },
    "exclude": [
        "wwwroot",
        "node_modules",
        "bower_components"
    ],
    "publishExclude": [
        "node_modules",
        "bower_components",
        "**.xproj",
        "**.user",
        "**.vspscc"
    ],
    "compilationOptions": {
        "warningsAsErrors": true
    }
}

-

{
    "version": "1.0.0-*",
    "description": "",
    "authors": [ "author" ],
    "tags": [ "" ],
    "projectUrl": "",
    "licenseUrl": "",

    "dependencies": {
        "SSI.Domain": "",
        "SSI.Service": "",
        "DocumentFormat.OpenXml": "2.5.0"
    },

    "frameworks": {
        "dnx451": {
            "dependencies": {
                "System.Collections": { "version": "4.0.0.0", "type": "build" },
                "System.Linq": { "version": "4.0.0-beta-23109", "type": "build" },
                "System.Threading": { "version": "4.0.10-beta-23109", "type": "build" },
                "Microsoft.CSharp": { "version": "4.0.0-beta-22816", "type": "build" }
            },
            "frameworkAssemblies": {
                "WindowsBase": { "version": "4.0.0.0", "type": "build" }
            }

        }
    }
}

我已经尝试删除一些包,运行 一个 dnu 恢复以查看错误是否仍然存在并且它一直存在,所以我开始 运行 没有想法......

如果没有看到整个项目很难判断,但我猜第二个 JSON 片段来自您的图书馆。我的猜测是您的库导致了错误,并且只是被报告到您的 Web 应用程序中。

这里有一些想法:

  • 将您的 frameworks:dnx451:dependencies 移至 frameworks:dnx451:frameworkAssemblies。
  • 删除那些 System.* 包中的 -beta 标识(很可能是它试图获取 Nuget 包而不是使用您的本地系统库)
  • 将 System.* 版本号更改为“4.0.0.0”
  • 切换到更简洁的引用语法(即删除 "version" 和 "type",并仅在引号中指定版本,例如 "System.Linq": "4.0.0.0")
  • 删除Microsoft.CSharp

当我将 class 库添加到 Web 项目时,我 运行 陷入了这个问题。当我添加 class 库时,project.json 文件框架看起来像这样 ...

  "frameworks": {
    "dotnet": { }
  }

当我匹配我的网络应用程序的框架时,错误就解决了。

  "frameworks": {
    "dnx451": { },
    "dnxcore50": { }
  }