Nuget restore fails to restore all the files on VSTS build if using project.json files
We are currently working on updating a Windows 8 application to be a Windows 10 Universal application. This has caused a few problem on a TFS vNext automated build box. The revised solution builds fine of the developers box and fine on the build VM if opened in Visual Studio, but fails if built via the VSTS vNext build CI MSBuild process showing loads of references missing.
Turns out the issue was due to Nuget versions.
The problem was that as part of the upgrade the solution had gained some new projects. These used the new project.json file to manage their Nuget references, as opposed to the old packages.config file. Visual Studio 2015 handles these OK, hence the build always working in the IDE, but you need Nuget.exe 3.0 or later for it to handle the new format. The version of Nuget installed as part of my vNext build agent was 2.8. So no wonder it had a problem.
To test my assumptions I added a Nuget Installer task to my build and set an explicit path to the newest version of Nuget.
Once this was done my build was fine.
So my solution options are
- Don’t use the agents shipped with TFS 2015, get newer ones fro VSTS this has a current version of Nuget (just make sure your agent/server combination is supported. I have had issues with the latest VSTS agent and a TFS 2015 RTM instance)
- Manually replace the version of Nuget.exe in my build agent tools folder – easy to forget you did but works
- Place a copy of the version of Nuget.exe I want on each build VM and reference it s path explicitly (as I did to diagnose the problem)
The first option is the best choice as it is always a good plan to keep build agents up to date