Search code examples
asp.net-mvc-5nugetasp.net-corednx

NuGet not working properly with Asp5-Mvc6


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.


Solution

  • 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.