Cannot execute nuget restore from batch file in Freestyle project

I am using a Jenkins Freestyle project. One of the steps is to run a batch command to restore nuget packages after the repo has been cloned. Please excuse me if this question has been asked a thousand times! I’m new to Jenkins and did not find ‘nuget’ under categories or tags, so I’m posting a request for help.
Here is the batch command and results, showing in the Console Window.
nuget.exe restore …\EGMManager\EGMManager\packages.config -PackagesDirectory …\EGMManager\packages (there are only two dots in markup)
‘nuget.exe’ is not recognized as an internal or external command,
operable program or batch file.
I checked plugins, and the only one I saw was for " NugetVersion1.1

This plugin allows to trigger a build when a NuGet dependency has an updated versionpublish NuGet packages to NuGet repositories using secured api keys". That does not sound like a nuget package handler.
Thanks in advance.
Notes:

  1. I’m building for Windows, Visual Studio 2019
  2. When I run “where nuget” on my local machine, I see:
    C:\Users\gmorris\AppData\Local\Microsoft\WindowsApps\nuget.exe

sounds like a path issue

inside of jenkins, can you run a job that does bat('echo %PATH%') and see if it contains C:\Users\gmorris\AppData\Local\Microsoft\WindowsApps` If not, I would recommend configuring path on your agent screen

1 Like

My understanding is that this is running on a Jenkins server, not my local machine. I ran a batch command to show the contents of C:\Users on the Jenkins server running this pipeline, and there is no gmorris folder. Output follows. (Bolding here with two asterisks seems hit-or-miss.)

**C:\WINDOWS\system32\config\systemprofile\AppData\Local\Jenkins\.jenkins\workspace\GameServer>dir \Users**
 **Volume in drive C has no label.**
** Volume Serial Number is 8C2E-DEBB**

** Directory of C:\Users**

**12/01/2020  09:34 AM    <DIR>          .**
**12/01/2020  09:34 AM    <DIR>          ..**
**12/01/2020  09:09 AM    <DIR>          Public**
**08/02/2022  02:48 PM    <DIR>          replay**
**               0 File(s)              0 bytes**
**               4 Dir(s)  26,068,054,016 bytes free**

I need to know if nuget.exe resides on the Jenkins server, and it so, where.

btw 3 backticks is a code block

I’m not sure how we would know what is installed on your server. If you didn’t setup jenkins, can you speak to who did, and get them to install nuget?

I used dir c:\nuget.exe /s in an attempt to find it, and it was found at C:\Users\replay\Download.
I added that path with set path=%PATH%;C:\Users\replay\Download and now my restore commands work.
I can’t explain why it’s set up like this, nuget installed but no path set up to run it. I’m in my third week at this job and many are out for the holidays.