NuGet与Asp5-Mvc6无法正常工作

时间:2015-11-25 15:03:36

标签: asp.net-mvc-5 nuget asp.net-core dnx

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

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

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

1 个答案:

答案 0 :(得分:0)

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

我们正在努力将所有恢复逻辑移至nuget

相关问题