NuGet 无法与 Asp5-Mvc6 一起正常工作

NuGet not working properly with Asp5-Mvc6

在新的 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.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 上找到的规范,命令行工具应该理解 json 配置文件:https://docs.nuget.org/Consume/ProjectJson-Intro

使用新的包恢复工具 dnu 时,没有问题 - 它只获取 nuget 包并忽略程序集依赖项。

一种解决方案是为 project.json 文件调用 DNU,为旧的 packages.config 调用 nuget - 但这并不方便。

目前的情况是,您需要使用dnu restore恢复project.json个项目,nuget restore恢复.csproj个项目。

不过,我们正在努力将所有还原逻辑移至 nuget