我在恢复ASP.NET 5/ASP.NET Core 1.0的依赖项时遇到了错误。
看起来,Microsoft.AspNet.Mvc
的几个依赖项(即Microsoft.CodeAnalysis.CSharp
/ .Common
)被固定在似乎已过时的包上。
这需要使用dotnet
cli工具并同时针对.NET Vanilla和.NET Core。
是否有任何方法可以让Mvc引用与Core兼容的CodeAnalysis版本?
在Visual Studio 2015(v14.0.24729.00 Update 1)中重现步骤:
- 文件> 新建> 项目> Web> ASP.NET Web应用程序
- API.NET 5模板> Web API
- 打开PM,运行命令
dotnet restore
输出:
info : Restoring packages for C:\PATH_TO_SOLUTION\WebApplication2\src\WebApplication2\project.json...
error: Microsoft.CodeAnalysis.CSharp 1.1.0-rc1-20151109-01 is not compatible with DNXCore,Version=v5.0.
error: Microsoft.CodeAnalysis.Common 1.1.0-rc1-20151109-01 is not compatible with DNXCore,Version=v5.0.
error: Some packages are not compatible with DNXCore,Version=v5.0.
error: Microsoft.CodeAnalysis.CSharp 1.1.0-rc1-20151109-01 is not compatible with DNXCore,Version=v5.0 (win7-x64).
error: Microsoft.CodeAnalysis.Common 1.1.0-rc1-20151109-01 is not compatible with DNXCore,Version=v5.0 (win7-x64).
... (loads more errors) ...
project.json
文件包含:
{
...
"dependencies": {
...
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
...
}
...
"frameworks": {
"dnx451": { },
"dnxcore50": { }
},
...
}
"dependencies"
里面,那么两个框架都会出现解析错误。 - dav_idotnet restore -s https://api.nuget.org/v3/index.json
,然后引用的包就安装好了。然后再运行dotnet build
就可以正常工作了! - dav_iMicrosoft.CodeAnalysis.Common 1.1.1与DNXCore,Version=v5.0不兼容
的错误。 - Greg Ennis