0
votes

We have a build definition in place created in TFS 2017, which builds a .net solution that has dependency on some of our NuGet packages, during compilation the solution restores the NuGet package from packages (global-packages) folder present at this path %userprofile%\.nuget\packages instead of downloading latest one from our internal feed.

I saw a command at this page to avoid using the global-packages folder, but when I added the nuget locals global-packages -clear argument in NuGet installer task, which is used to restore the nuget packages, the task failed with the below error saying unknown option -Clear.

The NuGet Version I am using is 3.5.0 in the task.

2019-09-05T09:27:18.8819742Z ##[section]Starting: NuGet restore $(build.sourcesdirectory)/IntelliSuiteService.sln
2019-09-05T09:27:18.8819742Z ==============================================================================
2019-09-05T09:27:18.8819742Z Task         : NuGet Installer
2019-09-05T09:27:18.8819742Z Description  : Installs or restores missing NuGet packages
2019-09-05T09:27:18.8819742Z Version      : 0.2.31
2019-09-05T09:27:18.8819742Z Author       : Microsoft Corporation
2019-09-05T09:27:18.8819742Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613747)
2019-09-05T09:27:18.8819742Z ==============================================================================
2019-09-05T09:27:19.4601187Z [command]C:\Windows\system32\chcp.com 65001
2019-09-05T09:27:19.4757465Z Active code page: 65001
2019-09-05T09:27:19.5069958Z Detected NuGet version 3.5.0.1938 / 3.5.0
2019-09-05T09:27:19.5226206Z SYSTEMVSSCONNECTION exists true
2019-09-05T09:27:19.5226206Z [command]F:\Builds\NextGen_Gated\_tasks\NuGetInstaller_333b11bd-d341-40d9-afcf-b32d5ce6f23b\0.2.31\node_modules\nuget-task-common\NuGet\3.5.0\NuGet.exe restore -NonInteractive F:\Builds\NextGen_Gated\2\s\SuiteService.sln -NoCache nuget locals global-packages -Clear
2019-09-05T09:27:20.1007732Z Unknown option: '-Clear'
2019-09-05T09:27:20.1163983Z ##[error]Error: F:\Builds\NextGen_Gated\_tasks\NuGetInstaller_333b11bd-d341-40d9-afcf-b32d5ce6f23b\0.2.31\node_modules\nuget-task-common\NuGet\3.5.0\NuGet.exe failed with return code: 1
2019-09-05T09:27:20.1163983Z ##[error]Packages failed to install
2019-09-05T09:27:20.1320334Z ##[section]Finishing: NuGet restore $(build.sourcesdirectory)/SuiteService.sln
1
You need to run it in separately, not with the nuget restore command. - Shayki Abramczyk
@ShaykiAbramczyk separately but with which task? any batch task would work? - SRP
Yes :) or just log in to your agent machine and run it once on the command line. - Shayki Abramczyk
Its giving me Unknown command: 'nuget' error, when i provided it the follwoing command in cmd "F:\srp\NuGet\3.5.0\NuGet.exe nuget locals global-packages -clear" - SRP
Try without nuget (because you already give the exe path) - Shayki Abramczyk

1 Answers

0
votes

You should run the command separately from the nuget restore command.

You can can log in to the agent machine and run it from the command line, or in the build add a command line or batch task that run the command.