Install-Package & NuGet Package install location - where installed to?

HankCa picture HankCa · Dec 13, 2017 · Viewed 16.1k times · Source
> nuget                                                                                                         
nuget : The term 'nuget' is not recognized as the name of a cmdlet, function, script file, or operable program. ...

> find-package -name nuget | Install-package -verbose
VERBOSE: Skipping installed package NuGet 1.3.3.

> nuget                                                                                                         
nuget : The term 'nuget' is not recognized as the name of a cmdlet, function, script file, or operable program. ...

If it is installed, where is it installed? I searched across the drive and no other copies of nuget.exe exist except for the one I manually installed (but which is obviously not in the $PATH so surely it is not referring to that - I renamed it to double-check!).


Question update

I had an expectation from my Java experience and it seems like I was asking the wrong question.

My use case is below. Background first.

  • I am new to MS App development though have a decade of Java dev experience.
  • (Where i currently are) there is an old version of ASP.Net application that won't work with the dotnet cli.
  • The team here had hard coded (saved) dependencies and also created their build system to expect to find other dependencies such as in a Visual Studio install. Having my background I don't like this expectation, especially when it comes to scaling.
  • The existing build system uses MSBuild and makes use of .targets files

My use case is to run a build using defined (NOT PRE-DOWNLOADED) dependencies and on a server that has no expectation about the build environment apart from some key tools. Visual Studio is an IDE and I don't expect to find this on a server.

I have created dependencies in a packages.config file. I want to add nuget.exe to the build script (currently a build.bat but a powershell equivalent is preferred).

I know there is a lot of information out there, but with my lack of knowledge in this area tied to the fact that what I want to do is rooted somewhere around 2012 (I'm guessing), I'm not sure what to do.

Given what I do know, I thought all I wanted to do is:

  1. Install nuget at the start of the build.bat / build.ps1 script
  2. Run nuget to install the defined dependencies
    • I have downloaded nuget manually, run nuget restore and confirmed that it does what I want
  3. Run the build as before

The first attempt at asking this question was to address #1 from this list. I thought powershell could be used to download nuget.exe and then the build script could call nuget restore.

Answer

Clijsters picture Clijsters · Dec 13, 2017

If it is installed, where is it installed?

Assuming you are on a Windows machine, PowerShell packages are usually installed in C:\Program Files\WindowsPowerShell\Modules (global) or C:\Users\%USERNAME%\Documents\WindowsPowerShell\Modules (CurrentUser).

nuget.exe specifically is installed - yeah, just where you install it; quoting from NuGet CLI Reference (MSDocs):

Installing nuget.exe

  1. On Mac and Linux, install Mono 4.4.2 or later.
  2. Visit nuget.org/downloads and select the version of NuGet you want.
  3. Each download is the nuget.exe file directly. Instruct your browser to save the file to a folder of your choice. The file is not an installer; running it from the browser won't show anything.
  4. Add the folder where you placed nuget.exe to your PATH environment variable to use the CLI tool from anywhere.

This seems somewhat confusing, doesn't it? Keep in mind that there are 3 different packages/applications:

  1. NuGet CLI (like referenced)
  2. NuGet PowerShell Package / Package Manager Console (What you are searching for I think) exports own Install-Package
  3. PowerShell's PackageManagement Package (Which also an Install-Package cmdlet)