3
votes

I am having problems with NuGet: it's actually driving me crazy! I am trying to make a TFS build run for a solution that includes nuget.exe. I don't have any issues running it from Visual Studio on my local workstation, but when I queue a new build in the TFS server, the build fails with these very known errors:

D:\<...SolutionPath...>.nuget\nuget.targets (88): Package restore is disabled by default. To give consent, open the Visual Studio Options dialog, click on Package Manager node and check 'Allow NuGet to download missing packages during build.' You can also give consent by setting the environment variable 'EnableNuGetPackageRestore' to 'true'.

D:\<...SolutionPath...>.nuget\nuget.targets (88): The command ""D:\<...SolutionPath...>.nuget\nuget.exe" install "D:\<...SolutionPath...>\packages.config" -source "" -RequireConsent -solutionDir "D:\<...SolutionPath...>\ "" exited with code 1.

The problem is: I already set the EnableNuGetPackageRestore to true in the TFS Build server, but it's still throwing the same error. I also tried running nuget.exe with the same parameters FROM a cmd windows in the same TFS server and I don't have any issues.

BTW, this is the content of my NuGet.config:

<configuration>
  <solution>
    <add key="disableSourceControlIntegration" value="true" />
  </solution>
  <packageRestore>
    <add key="enabled" value="true" />
  </packageRestore>
</configuration>

Any ideas?

Thanks in advance.

2

2 Answers

2
votes

Please check that your TFS build service account is the same as the account you used to make the change. Also reboot the server to make sure the environment variable makes it the service.

1
votes
  1. Log on to the build server using the same account that executes the build.
  2. Open Visual Studio.
  3. Install the NuGet package manager in Visual Studio.
  4. Restart Visual Studio.
  5. Tools --> Options --> Package Manager --> General: tick 'Allow NuGet to download missing packages during build'.
  6. Enable package restore in your solution.