6

I'd like to know where Visual Studio keeps it's copy of nuget.exe so that I can use that path in a custom msbuild target I'm planning to do.

Some time ago, NuGet package restore was not automatic in Visual Studio: you had to import a custom .targets file so that packages were restored before building. At the time, a copy of nuget.exe was kept with each solution in a .nuget folder. Nowadays, Visual Studio does this automatically when building, which indicates to me that somewhere there is a nuget.exe file that it uses to restore the packages for the solution.

Ideally I'd like to know it's path using MSBuild macros, because then it would not matter at which machine the projects are being built, the path will always point to the correct place.

For those who may be curious, I want to start distributing an internal library we have on a privage nuget feed, and intend to build the nupkg files using nuget.exe on build time. I know about NuGetter, but it is a bit more complex and inflexible than I wanted, so I feel a pure msbuild approach would be simpler to start with at least.

julealgon
  • 7,072
  • 3
  • 32
  • 77
  • Wow, really? This is quite obvious now that I think of it :P. It never crossed my mind that nuget.exe itself could be in a package. This actually solves the problem quite nicely! If you could word that as an answer I'd mark it. I feel this might be in another question but, how does the nuget extension imports the packages then if not thought the .exe? Does the .exe and the extension call a common code library that does the stuff (it would be how I'd code things, but I'm not sure how it works). I did a search in windows and did not find the exe anywhere, so I was puzzled. – julealgon Jan 27 '15 at 17:00
  • 1
    The NuGet Package Manager in Visual Studio makes a lot of use of a shared NuGet.Core.dll which is also used by NuGet.exe. If you search in Program Files you should find NuGet.Core.dll and the other dlls used. However both the NuGet addin in Visual Studio and NuGet.exe have a reasonable amount of code that is written to initiate the restore process. – Matt Ward Jan 27 '15 at 17:23
  • @MattWard That lines up with what I was thinking. Makes a lot of sense now, thanks. – julealgon Jan 27 '15 at 17:53

1 Answers1

6

I'd like to know where Visual Studio keeps it's copy of nuget.exe

It doesn't have one. Nuget is an add-in, just DLLs. On my machine it is stored in the C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\clzwekqw.krr directory. The "clzwekqw.krr" part of the directory name is not going to repeat from one machine to the next, it was dynamically created. A basic mechanism to avoid having add-ins step on each other's toes.

You can get Nuget.exe, it is available through Nuget :) Obtain the Nuget.CommandLine package, the current version's project page is here. It will be installed as usual, in a subdirectory of your project. Currently packages\NuGet.CommandLine.2.8.3\tools, just the .exe

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536