NuGet not working properly with Asp5-Mvc6

可紊 提交于 2019-12-13 07:37:18

问题


When restoring packages in the new xproj project types, there are the new package config in the 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 restores theese with no problem.

When the .xproj depends on normal .proj files, you sometimes needs to create wrappers, and write the dependency like this:

"frameworks": {
        "dnx46": {
            "dependencies": {
                "SomeOldProjectAssembly": "1.0.0-*"
            }
        }
    }

The wrapper is not important here.

When using nuget to restore packages, in this project.json file: nuget restore .\project.json the nuget packages is restored, but Nuget.exe also tries to restore the assemply dependencies.

I get this error from 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.

From the specs found on nuget, the command line tool should understand the json config file: https://docs.nuget.org/Consume/ProjectJson-Intro

When using the new package restore tool dnu, there is no problems - it only fetches the nuget packeges and ignores the assembly dependencies.

One solution is to call DNU for the project.json files, and nuget for the old packages.config - but thats just not convenient.


回答1:


The current situation is that you need to use dnu restore to restore project.json projects and nuget restore for .csproj projects.

We are working on moving all restore logic to nuget though.



来源:https://stackoverflow.com/questions/33919834/nuget-not-working-properly-with-asp5-mvc6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!