nuget restore with project.json: should Nuget Package Manager and Nuget.EXE restore the same way?

518 views Asked by At

NPM: Package Manager Console Host Version 3.4.4.1321

nuget.exe: NuGet Version: 3.5.0.1938

Visual Studio: 2015 Enterprise

Attempting to restore and build a .nupkg file to bin gets different results, depending on if I use Visual Studio/NPM or Command Line/nuget.exe.

I can get the .dll files to output to bin with CL restore/build, but my .xml files in contentFiles folder ONLY write to bin with nuget.exe (command line restore and build), not with NPM (Visual Studio restore and build)

Should I not get the same output to bin folder and to project.lock.json regardless of what restore method I use? After inspection of project.lock.json I notice that the Command Line restore produces DIFFERENT output than a Visual Studio restore. That's why I am getting different output in the BIN.

2

There are 2 answers

1
user5855178 On

I found a work around until Microsoft fixes this defect:

In Visual Studio 2015 Tools Menu

  1. Select Options

  2. Select Nuget Node

  3. UNCHECK these two options:

Allow Nuget to Download Missing Packages

Automatically Check for Missing Packages During Build

  1. In your EXE Project Properties Select Build Events Left Tab
  2. Edit the pre-build event to add this statement

C:\NuGet\nuget.exe restore $(SolutionPath)

Assumptions: Copy nuget.exe to the directory listed above: v 3.5 is the version I test with

Results:

This simulates the auto-restore feature that visual studio does. I find it's actually BETTER because you don't get that tedious modal window that pops up.

Try it out guys! You get the same results, but BETTER!

0
Martin Ullrich On

The fix for this is simply to make sure you have the latest NuGet visual studio extension installed - for VS 2015 this is the 3.5 VSIX. You can download it directly from NuGet's download site.