3
votes

I have recently started to implement an automated build for our software suite using TFS. I am trying to install as little as possible on the build server and would like to avoid checking in third party libraries to our source repository.

One of our projects fails the build with with a missing dependency:

<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />

This is not surprising, as I don't have Visual Studio (or Team Explorer etc.) installed on the build server. In an effort to work around this issue, I am trying to use NuGet with automatic package restore to provide the appropriate library (MSBuild.Microsoft.VisualStudio.Web.targets). I have read a ton of posts both here and elsewhere, but have not been able to get this to work properly. Basically, I:

  1. Set an environment variable on the build server: EnableNuGetPackageRestore=true
  2. Followed the instructions at: http://docs.nuget.org/docs/workflows/using-nuget-without-committing-packages
  3. Added all files in SolutionDir.nuget to the TFS repository.
  4. Add the packages folder and respositories.config to the TFS repository.
  5. Verified that nuget.targets was referenced from the offending project.
  6. Verified that 'RestorePackages' was set to true in the offending project.
  7. Shelved all these items and queued a private build with the proper shelveset.

The build runs, but the nuget packages are never downloaded. Further to that, I don't see any log entries for any 'RestoreCommand' (or other items from the nuget.targets) in the build log file. It is like the nuget.targets is completely ignored. I'm hoping I've just been looking at this too long and have missed some simple step.

Edit: I should have mentioned that the solution builds fine on a local machine. I have updated the project references to reference the libraries from NuGet. If I delete all the local packages it downloads them and builds properly.

1
How did you set the environment variable? Are you sure it's not per user and did you bounce the machine to ensure it was applied to all processes, etc? - Nick Nieslanik

1 Answers

1
votes

I know this is an old question but here is how I got this working.

I followed the instructions here so I do not have to add the packages folder to TFS: http://docs.nuget.org/docs/workflows/using-nuget-without-committing-packages

I then had to use the simple build file that is mentioned in this link http://docs.nuget.org/docs/reference/package-restore-with-team-build which simply triggers the package restore beforehand.

All I had to change from the build file was the path to my solution file and the nuget.exe as mine differed.

I then configured TFS to use the build.proj file rather than the solution.

Please note I also upgraded to nuget 2.7 so I didn't have to include the .targets file.