0
votes

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
How did you restore the .nupkg file to bin folder? Is the repositoryPath set to the bin folder? As far as I know, NuGet Restore only restores files in the packages directory (\packages folder ), .dll files will not copy to bin folder after restore. Does you mean you have build your project, then get the .dll file to bin? Not sure the detail steps for this question, Could please share us more detail steps to us so that we could reproduce this issue?Leo Liu-MSFT
I mean I do a restore, the restore updates project.lock.json, and then I do a build based on the restore/project.lock.json results. I was expecting the Visual Studio restore/build and the Command Line restore/build to produce the same results: they don't. I can send you the .nupkg to try out if you want and have the environment to test this. Visual Studio restore/build and command line restore/build produce different results with the versions I use above.user5855178

2 Answers

0
votes

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
votes

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.