{Solved} Nuget is not recognized as internal or external command

Hello everyone and welcome to my blog. Today’s blog is little different from my usual blogs on Power Platform and Dynamics 365. However any developers in Dynamics and Power platform must be familiar with Nuget.

Through my blog I share interesting tips and discuss on latest releases of Microsoft.NET technologies, Dynamics 365 and Power Platform, SharePoint and Client scripting libraries. Please subscribe to my blog to stay updated.

Coming to the problem statement. We were trying to generate the .nuspec file for our project. To do that we were running the following command using Visual studio command prompt.

nuget spec -force <path_to_csproj_file>

However when we ran the command, we got the below error.

nuget is not recognized as internal or external command

It was rather surprising because we were able to add Nuget packages through visual studio. However nuget was not recognized by the command line.

We found an easy workaround for this. The first thing to do if you are getting this error is to download the latest version of Nuget.exe.

Once downloaded, you need to place that in a specific location. It can be any location I would suggest to put it under C:\users\<username>\.nuget folder. This folder should already be there if you are using Visual studio. If not please create it.

Once done, the final step is to ensure that this folder path is set in your Environment variables.

Go to control panel and open the system properties window. Click on Environment variables.

Enter the path to add it as environment variable.

All set and done. You should now be able to run the Nuget commands from your command line without any issues.

I hope this helped. If you have liked the post and if this post has helped you, please subscribe to my blog.

Debajit Dutta