从ASP.NET 5引用.NET 4.6项目会导致生成错误

Bow*_*opa 9 asp.net-core

在我的ASP.NET 5 RC1项目中(仅针对dnx46)我正在尝试添加一个针对.net 4.6的(经典)类库项目的引用.

我在构建时遇到此错误:...\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1819,5):警告MSB3274:无法解析主要引用"...\ClassLibrary1.dll"因为它是针对".NETFramework,Version = v4.6"框架构建的.这是比当前目标框架".NETFramework,Version = v4.5.1"更高的版本.

为什么会这样?我的ASP.NET 5项目没有针对4.5.1.根据project.json文件,它只针对dnx46.在任何地方我都找不到.net 4.5.1.

这是我的WebApplication项目的project.json:

{
  "version": "1.0.0-*",
  "compilationOptions": {
    "emitEntryPoint": true
  },

  "dependencies": {
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final"
  },

  "commands": {
    "web": "Microsoft.AspNet.Server.Kestrel"
  },

  "frameworks": {
    "dnx46": {
      "dependencies": {
        "ClassLibrary1": "1.0.0-*"
      }
    },
  },

  "exclude": [
    "wwwroot",
    "node_modules"
  ],
  "publishExclude": [
    "**.user",
    "**.vspscc"
  ]
}
Run Code Online (Sandbox Code Playgroud)

这是"包装"过程为我的ClassLibrary项目创建的project.json:

{
  "version": "1.0.0-*",
  "frameworks": {
    "net46": {
      "wrappedProject": "../../ClassLibrary1/ClassLibrary1.csproj",
      "bin": {
        "assembly": "../../ClassLibrary1/obj/{configuration}/ClassLibrary1.dll",
        "pdb": "../../ClassLibrary1/obj/{configuration}/ClassLibrary1.pdb"
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

小智 1

如果您尚未升级您的实用程序和运行时版本,请尝试升级它。

  • dnvm升级

然后从 shell 指向您的工作\项目文件夹,清理缓存并恢复项目包

  • dnu 清除 http 缓存
  • dnu恢复

然后尝试构建它

  • dnu构建