4
votes

I have a solution with multiple projects in it checked in to TFS (Visual Studio Team Services). I only want one of those projects (and therefore its dependencies) to build and deploy to an Azure Web Site I have created. My solution and its projects follow the NuGet 2.7+ Automatic Package Restore method according to this guide. Everything works as expected in my local Visual Studio 2013 environment.

I created a very basic deployment build in Team Services using this guide, but the build fails with this error regarding NuGet:

******************************************************************************
Running tasks
******************************************************************************
******************************************************************************
Starting task: Build solution $/Path/To/My/Project.csproj
******************************************************************************
Executing the powershell script: C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\default\tasks\VSBuild\1.0.16\VSBuild.ps1
C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\default\agent\worker\tools\NuGet.exe restore "C:\a\1\s\Path\To\My\Project.csproj" -NonInteractive
MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin'.
Cannot determine the packages folder to restore NuGet packages. Please specify either -PackagesDirectory or -SolutionDirectory.
Unexpected exit code 1 returned from tool NuGet.exe

My question is: how exactly do I specify either -PackagesDirectory or -SolutionDirectory? I wasn't able to find any documentation regarding this.

Or, perhaps I am going about this in the wrong way altogether?

1

1 Answers

6
votes

First you seem to use an outdated approach for NuGet Package restore (with .nuget folder in version control). See this blog post for a writing about the limitations of this approach.

If you need to pass specific arguments to nuget.exe for package restoring you should use the separate "NuGet Installer" task, which has a "NuGet Arguments" parameter where you can provide further option to the nuget.exe restore command.

If you use the "NuGet Installer" task for package restore you can disable the "Restore NuGet Packages" option in the "Visual Studio Build" task.