‘nuget’ is not recognized as an internal or external command, operable program or batch file

Issue Description

NuGet commands give errors in CLI or PMC (Package manager console)

CLI

'nuget' is not recognized as an internal or external command,
operable program or batch file.

nuget is not recognized as an internal command

Package Manager Console,

The term ‘nuget’ is not recognized as the name of a cmdlet, function, script file, or operable program

The term'nuget' is not recognized as the name of a cmdlet

Resolution

NuGet is a tool for development platform using which developers can create, share, and consume useful code.

It provides the ability to create and consume packages.

The issue seems to be missing Nuget.exe in either the local project Space or at the global level settings on the target machine.

This issue can be solved easily at the project scope or global scope by following the below instruction.

Install NuGet at Local Project Scope

Nuget.exe can be installed easily using the Nuget repository.

This exe is available as NuGet, CommandLine package in nuget.org repository

nuget not found

Now let’s run the NuGet commands using PMC, Nuget command will be recognized as below,

blank

Install Nuget package command line – Globally accessible

Certainly, sometimes we don’t want to install nuget.exe at the individual project level.

Installing or accessing Nuget.exe and its commands could be useful many times.

The one-time setup helps multiple downloads and helps to centralize commands usage of nuget.exe on local machines and Build machines.

This can be achieved in 2 steps

Step 1:

Get the location of nuget.exe already installed.

[If installing the first time – You can get the nuget.exe either directly downloading it from https://www.nuget.org/downloads]

OR

In the above steps when we already installed nuget.commandline its default location will be stored at the below location,

Default location

C:Users[user-name].nugetpackagesnuget.commandline5.5.1tools

Note: Please check your version depending on the system settings

nugetexe not found

Additionally, the NuGet exe location can be found by right-clicking the package in the project solution and finding the location.

Step2:

Either way, if you obtain the path of the nuget.exe, please copy the path and add it to the PATH variable in the Environment Variable settings.

blank

You shall see NuGet commands are available and accessible from anywhere in the Machine.

From PMC:

blank

From Command Prompt CLI

nuget not recognized

From Powershell

nuget is not recognized

If issue still persisting?

  • Please close any open command prompt or shell windows and try running the command again.

  • Please try restarting the machine for any other issues.

References:

Did the above steps resolve your issue? Please sound off your comments below!

Happy Coding !!



Please bookmark this page and share it with your friends. Please Subscribe to the blog to receive notifications on freshly published(2024) best practices and guidelines for software design and development.



9 thoughts on “Resolved – ‘nuget’ is not recognized as an internal or external command, operable program or batch file

Leave a Reply

Your email address will not be published. Required fields are marked *