How to get the location of nuget.exe used by Visual Studio?

I have seen this question asked in a MSDN forum, and it’s the same question that I asked myself some months ago when I decided to adopt MSBuild to replace a custom builder that I was using for years, and as part of the build I wanted to download the latest source code.

The answer is that Visual Studio doesn’t use nuget.exe, so you can’t get its location. Instead, Visual Studio uses an extension for NuGet. For Visual Studio 2015, if you go to the folder C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\, you will find it in some of the folders with random names where machine-wide Visual Studio extensions are installed. For Visual Studio 2017 Community Edition, you can find it inside C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\NuGet:

Furthermore, you may want to use the Build Tools 2017 instead of the full Visual Studio 2017 IDE on a build machine.

So, how can you get nuget.exe installed on a build machine?  Easy! You need to download it from: