nuget is not a recognized as an internal or external command
Asked Answered
G

7

63

While running a batch file, I get the below error: nuget is not a recognized as an internal or external command It's not working from command prompt. Have a look at the below screenshot. readably sized image

Gadwall answered 10/8, 2017 at 10:9 Comment(0)
S
71

nuget is not a recognized as an internal or external command

That because NuGet is a external command, can not be recognized by Windows in an arbitrary directory, you should type the "NuGet" or "NuGet.exe" in the path where NuGet.exe exists and if you want type it in an arbitrary directory, you should download the NuGet.exe (Not VSIX) from NuGet.org and set the local path of NuGet.exe into your path environment variable.

Sling answered 10/8, 2017 at 12:10 Comment(1)
Make sure that you place the nuget.exe file in a high level folder like your user or it won't be accessible.Lentiginous
T
87

This happens when either you are not in the directory where the nuget.exe is located or your environment variables are not set for it.

  1. Make sure you have downloaded NuGet.exe.
  2. Navigate to it and right click, then click on properties.
  3. Copy the location of it.
  4. Navigate to Control Panel > System > Advanced System Settings > Environment Variables.

Windows 10

  1. Double click the variable Path click add new, paste in the location of the nuget.exe.

  2. Restart Command Prompt and the issue should be fixed.

Other operating Systems

  1. Double click the variable Path, If there is no other locations simply paste it in. If there is add a semi colon to the end of it and the paste it in.

  2. Restart Command Prompt and the issue should be fixed.

Trainer answered 23/3, 2018 at 16:26 Comment(3)
Restart Command Prompt and the issue should be fixed, is important one.Australasia
Note for anyone doing this in a hurry: the location is the path of the folder that contains nuget.exe, not the full path of nuget.exe (i.e. your location path does not have nuget.exe on the end)Niemi
The environment variable is called "Path". Maybe it's my dyslexia or maybe it's the lack of quotes, but I read step 5 at least 10 times before I understood that. Posting this for whoever is dysfunctional in the same way I am.Coincide
S
71

nuget is not a recognized as an internal or external command

That because NuGet is a external command, can not be recognized by Windows in an arbitrary directory, you should type the "NuGet" or "NuGet.exe" in the path where NuGet.exe exists and if you want type it in an arbitrary directory, you should download the NuGet.exe (Not VSIX) from NuGet.org and set the local path of NuGet.exe into your path environment variable.

Sling answered 10/8, 2017 at 12:10 Comment(1)
Make sure that you place the nuget.exe file in a high level folder like your user or it won't be accessible.Lentiginous
P
40

Instead of using nuget.exe in your path, use .net version dotnet nuget

Publisher answered 24/4, 2018 at 12:13 Comment(2)
Using this way you have to be aware of the fact that many features of the "normal" nuget are missing, like "nuget restore".Swink
For the missing restore feature (from Nuget), try "dotnet restore" on the CLI in the solution or project folder.Newell
C
14
  1. Download the Nuget Exe, keep it in a folder you want to. For ex : D:\Software\Nuget
  2. Open Cmd prompt with the same path.
  3. To create this .nuspec file, execute the following command in a command prompt.

    D:\Software\Nuget>Nuget.exe spec enter image description here

Crane answered 25/9, 2018 at 15:1 Comment(0)
B
3

For .NET Core / .NET 5:

Use the command dotnet pack

Instead of using a .nuspec file you set those properties in your .csproj file, for example:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
    <PackageId>MyCompany.Project</PackageId>
    <Version>1.0.0.1</Version>
  </PropertyGroup>

...

</Project>

With above config, running dotnet pack will create a file named

MyCompany.Project.1.0.0.1.nupkg

For more details and config options, see: https://learn.microsoft.com/en-us/nuget/reference/msbuild-targets#pack-target

Bunsen answered 26/6, 2021 at 2:33 Comment(1)
Hi, i have few standalone projects which are not referenced anywhere, I want to include them as well in nuget package, please advise?Trundle
D
0

I follow this link and it work fine with me

How to Fix “not recognized as an internal or external command” in Windows

just add the path of the nuget in the path variable

Dorinedorion answered 28/10, 2019 at 11:11 Comment(0)
L
0

1 - Installing Package:

I followed this Microsoft documentation. Use the nuget.exe CLI in the package console

Note:- This configuration is specific to a project and this adds dependency to the projects package.config

2 - Installing exe:

You can also follow the below documentation, again from Microsoft to download and set the path to nuget.exe folder, as others in this thread has explained. NuGet CLI reference

Lesseps answered 8/1, 2021 at 7:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.