Answers: <p>When I did <code>echo %USERPROFILE%</code> from Jenkins it returned null. So I had to 
  manually set <code>USERPROFILE</code> value from Jenkins as environment variable. Also I had to set these</p>
  
  <p><code>APPDATA=%USERPROFILE%\AppData\Roaming</code></p>
  
  <p><code>LOCALAPPDATA=%USERPROFILE%\AppData\Local</code> </p>
  
Answers: CC BY-SA 4.0
Answers: 2018-08-08T21:00:22.900Z
Answers: 2018-08-08T21:00:22.900Z
Answers: dingcoder
Body: <p>When I check for dotnet version it is throwing an error </p>
  
  <pre><code>D:\jenkins\workspace\csharp-windows-test&gt;dotnet --version 
  17:58:06 System.ArgumentNullException: Value cannot be null.
  17:58:06 Parameter name: path1
  17:58:06    at System.IO.Path.Combine(String path1, String path2)
  17:58:06    at Microsoft.DotNet.Configurer.CliFolderPathCalculator.get_DotnetUserProfileFolderPath()
  17:58:06    at Microsoft.DotNet.Configurer.FirstTimeUseNoticeSentinel..ctor(CliFolderPathCalculator cliFolderPathCalculator)
  17:58:06    at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryClient)
  17:58:06    at Microsoft.DotNet.Cli.Program.Main(String[] args)
  17:58:06 
  </code></pre>
  
  <p>but when I search for 'where' it shows the location</p>
  
  <pre><code>17:58:06 D:\jenkins\workspace\csharp-windows-test&gt;where dotnet  
  17:58:07 C:\Program Files\dotnet\dotnet.exe
  </code></pre>
  
  <p>This is causing build failures. Can someone suggest a best way to resolve this </p>
  
  <p>Also I was able to execute the script on the machine directly without issues. This is only happening when called from Jenkins  </p>
  
Comments: CC BY-SA 4.0
Comments: 2018-08-08T15:12:44.697Z
Comments: What if you call the full path "C:\Program Files\dotnet\dotnet.exe" --version or "C:\Program Files\dotnet\dotnet.exe" --help? Do you get the same error?
Comments: Preston Martin
Comments: CC BY-SA 4.0
Comments: 2018-08-08T18:45:43.343Z
Comments: Im getting same error `D:\jenkins\workspace\csharp-windows-test>"C:\Program Files\dotnet\dotnet.exe" --version 
      System.ArgumentNullException: Value cannot be null.
      Parameter name: path1
      at System.IO.Path.Combine(String path1, String path2) `
Comments: dingcoder
Tags: <jenkins><continuous-integration><windows><builds><dotnet>
Title: Jenkins slave not able to find dotnet
UserDisplayName: dingcoder
ThreadText: # Jenkins slave not able to find dotnet
  
  (Asked by: username_0 on 2018-08-08)
  
  When I check for dotnet version it is throwing an error
  
  ```
  D:\jenkins\workspace\csharp-windows-test>dotnet --version 
  17:58:06 System.ArgumentNullException: Value cannot be null.
  17:58:06 Parameter name: path1
  17:58:06    at System.IO.Path.Combine(String path1, String path2)
  17:58:06    at Microsoft.DotNet.Configurer.CliFolderPathCalculator.get_DotnetUserProfileFolderPath()
  17:58:06    at Microsoft.DotNet.Configurer.FirstTimeUseNoticeSentinel..ctor(CliFolderPathCalculator cliFolderPathCalculator)
  17:58:06    at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryClient)
  17:58:06    at Microsoft.DotNet.Cli.Program.Main(String[] args)
  17:58:06 
  
  ```
  
  but when I search for 'where' it shows the location
  
  ```
  17:58:06 D:\jenkins\workspace\csharp-windows-test>where dotnet  
  17:58:07 C:\Program Files\dotnet\dotnet.exe
  
  ```
  
  This is causing build failures. Can someone suggest a best way to resolve this
  
  Also I was able to execute the script on the machine directly without issues. This is only happening when called from Jenkins
  
  **Tags:** jenkins, continuous-integration, windows, builds, dotnet
  
  > **Comments:**
  > **username_1**: What if you call the full path "C:\Program Files\dotnet\dotnet.exe" --version or "C:\Program Files\dotnet\dotnet.exe" --help? Do you get the same error?  
  > **username_0**: Im getting same error `D:\jenkins\workspace\csharp-windows-test>"C:\Program Files\dotnet\dotnet.exe" --version      System.ArgumentNullException: Value cannot be null.     Parameter name: path1     at System.IO.Path.Combine(String path1, String path2) `  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2018-08-08. Score: 0 | Accepted answer
  
  When I did `echo %USERPROFILE%` from Jenkins it returned null. So I had to
  manually set `USERPROFILE` value from Jenkins as environment variable. Also I had to set these
  
  `APPDATA=%USERPROFILE%\AppData\Roaming`
  
  `LOCALAPPDATA=%USERPROFILE%\AppData\Local`
  
  
  ---
  
  