Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Team Services Continuous Integration: NuGet Restore Task Failed

I am using Continuous Integration feature in Team Services (was Visual Studio Online). My build definition targets a specific project in a solution (not the whole solution), which is ClientUI MVC website.

The solution contains three projects:

  1. ClientUI
  2. AdminUI
  3. Client Services

enter image description here

The Build Definition for ClientUI Project:

Repository:

enter image description here

Nuget Installer Step: I have tried different params but not working. enter image description here

Visual Studio Build

enter image description here

Before trying to target the a single project, my build definition was targeting the whole solution with the following parameters:

  1. NuGet Installer -> Path to Solution: **\*.sln
  2. Visual Studio Build -> Solution: **\*.sln ; MSBuild Arguments: /p:outdir=$(build.artifactstagingdirectory)

It was working. However now, it generates this error in the Nugget Restore Task:

2016-04-22T21:07:00.6716725Z Set workingFolder to default: C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\1.98.1\tasks\NuGetInstaller\0.1.25
2016-04-22T21:07:00.8163908Z Executing the powershell script: C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\1.98.1\tasks\NuGetInstaller\0.1.25\NuGetInstaller.ps1


2016-04-22T21:07:01.5283529Z ##[error]Cannot find path 'C:\a\1\s\packages.config' because it does not exist.
2016-04-22T21:07:01.5439897Z C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\1.98.1\agent\worker\tools\NuGet.exe restore "C:\a\1\s\packages.config"  -NonInteractive


2016-04-22T21:07:03.0441507Z MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin'.


2016-04-22T21:07:03.0597010Z ##[error]Cannot determine the packages folder to restore NuGet packages. Please specify either -PackagesDirectory or -SolutionDirectory.
2016-04-22T21:07:03.0909881Z ##[error]Unexpected exit code 1 returned from tool NuGet.exe
like image 449
Hussein Salman Avatar asked Apr 22 '16 21:04

Hussein Salman


People also ask

How do I fix NuGet recovery failed?

Quick solution for Visual Studio usersSelect the Tools > NuGet Package Manager > Package Manager Settings menu command. Set both options under Package Restore. Select OK. Build your project again.

How do I force a NuGet package to restore?

Restore NuGet packagesNavigate to Tools > Options > NuGet Package Manager > General, and then select the Allow NuGet to download missing packages check box under Package Restore. Enabling Restore NuGet Packages. In Solution Explorer, right-click the solution, and then select Restore NuGet Packages.

How do I restore NuGet in Visual Studio?

In Visual Studio on Windows, you can restore packages automatically or manually. First, configure Package Restore through Tools > Options > NuGet Package Manager.

How do I reinstall NuGet restore?

In Tools -> Options -> NuGet Package Manager -> General you need to select the "Allow NuGet to download missing packages" option which allows NuGet to restore and the "Automatically check for missing packages during build in Visual Studio" which enables on build restore.


2 Answers

Try setting "Installation type" to "Install" for "Nuget Installer" task since you are using "packages.config" to install the packages. enter image description here

like image 55
Eddie Chen - MSFT Avatar answered Nov 03 '22 00:11

Eddie Chen - MSFT


For anyone curious, the source of the error about "Please specify either -PackagesDirectory or -SolutionDirectory" is that the build process is trying to issue a command similar to this:

C:\hostedtoolcache\windows\NuGet\4.4.1\x64\nuget.exe restore D:\a\1\s\MyProject\packages.config -PackagesDirectory packages -Verbosity Detailed -NonInteractive 

The below screenshots should help if you want to build a project (rather than the solution) and your nuget "packages" folder is at the solution-level.

Additionally, you may need to specify this as the "MSBuild Argument" in the build task of your project: /p:SolutionDir="/"

The csproj is your "solution."

If your "packages" folder is at the solution-level, then you want to have that as the Destination directory.

like image 27
paulyb Avatar answered Nov 03 '22 02:11

paulyb