【发布时间】:2015-11-26 01:10:09
【问题描述】:
在新的xproj项目类型中恢复包时,project.json中有新的包配置:
"dependencies": {
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-rc1-final",
"Microsoft.AspNet.Authentication.Facebook": "1.0.0-rc1-final",
"Microsoft.AspNet.Authentication.Google": "1.0.0-rc1-final",
....
}
Nuget 可以毫无问题地恢复这些。
当.xproj依赖于普通的.proj文件时,有时需要创建包装器,并像这样编写依赖:
"frameworks": {
"dnx46": {
"dependencies": {
"SomeOldProjectAssembly": "1.0.0-*"
}
}
}
包装在这里并不重要。
当使用 nuget 还原包时,在此 project.json 文件中:nuget restore .\project.json nuget 包已还原,但 Nuget.exe 也会尝试还原组件依赖项。
我从 Nuget.exe 收到此错误:
C:\SomePlace> nuget.exe restore .\project.json
MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin'.
Restoring packages for C:\SomePlace\project.json...
NotFound https://api.nuget.org/v3-flatcontainer/escenic.net/index.json 639ms
NotFound https://api.nuget.org/v3-flatcontainer/escenic.net.configgenerator/index.json 713ms
NotFound https://api.nuget.org/v3-flatcontainer/escenic.net.base/index.json 720ms
Unable to resolve SomeOldProjectAssembly (≥ 1.0.0--) for DNX,Version=v4.6.
Exception of type 'NuGet.CommandLineException' was thrown.
从nuget上的specs来看,命令行工具应该理解json配置文件:https://docs.nuget.org/Consume/ProjectJson-Intro
当使用新的包恢复工具dnu时,没有问题——它只获取nuget包并忽略程序集依赖。
一种解决方案是为project.json 文件调用DNU,为旧的packages.config 调用nuget - 但这并不方便。
【问题讨论】:
标签: asp.net-mvc-5 nuget asp.net-core dnx