无法解决目标框架“DNX,Version=v4.5.1"的以下依赖项 [英] Failed to resolve the following dependencies for target framework 'DNX,Version=v4.5.1'
问题描述
我使用的是 ASP.NET 5.0,我只想在新的 Core CLR 上运行,所以我从我的 project.json<中的依赖项中删除了
"dnx451": { }
/代码> 文件.我现在在 IIS 中启动时收到以下错误:
I'm using ASP.NET 5.0 and I wanted to run just on the new Core CLR, so I removed "dnx451": { }
from dependencies in my project.json
file. I now get the following error when I launch in IIS:
无法解析目标框架DNX,Version=v4.5.1"的以下依赖项:Microsoft.AspNet.Mvc 6.0.0-beta4Microsoft.AspNet.Server.IIS 1.0.0-beta4Microsoft.AspNet.Server.WebListener 1.0.0-beta4Microsoft.AspNet.StaticFiles 1.0.0-beta4
Failed to resolve the following dependencies for target framework 'DNX,Version=v4.5.1': Microsoft.AspNet.Mvc 6.0.0-beta4 Microsoft.AspNet.Server.IIS 1.0.0-beta4 Microsoft.AspNet.Server.WebListener 1.0.0-beta4 Microsoft.AspNet.StaticFiles 1.0.0-beta4
我的理解是 AspNet.Mvc 6 可以在 Core CLR 上运行?为什么我必须包含 dnx451
作为依赖项?
My understanding was that AspNet.Mvc 6 would run on Core CLR? Why then do I have to include dnx451
as a dependency?
我的 project.json
文件:
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
"Microsoft.AspNet.Mvc": "6.0.0-beta4",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta4",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta4",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta4"
},
"commands": {
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000"
},
"frameworks": {
"dnxcore50": { }
},
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
],
"publishExclude": [
"node_modules",
"bower_components",
"**.xproj",
"**.user",
"**.vspscc"
]
}
推荐答案
将 dnxcore50
指定为 project.json
中的依赖项与告诉解决方案目标不同那个dnx
.为了解决这个问题,我必须修改解决方案 global.json
文件以使用特定版本的 dnx
(即特定的 .Net 可执行文件).我还必须更改一些 using
语句以使用新的 Core CLR 库而不是 .Net 4.5 库.您将收到有关这些的智能感知和错误警告.
Specifying dnxcore50
as a dependency in project.json
is not the same as telling the Solution to target that dnx
. To fix this I had to modify the solution global.json
file to use a specific version of the dnx
(i.e. a specific .Net executable). I also had to change a few using
statements to use new Core CLR libraries instead of .Net 4.5 libraries. You will get intellisense and error warnings about these.
global.json
文件可以在解决方案节点下找到.我不得不添加sdk版本部分:
The global.json
file can be found under the Solution node. I had to add the sdk version part:
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-beta4"
}
}
请注意,您也可以在 GUI 中进行
Note that you can also edit this in a GUI:
强烈推荐 第 9 频道.
这篇关于无法解决目标框架“DNX,Version=v4.5.1"的以下依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!