I'm having kind of an odd problem with my Team Foundation Service build. I queue it up and it starts just fine, but then it fails with the following error:
C:\a\src\Platform\Prod\Platform.Web\Platform.Web.csproj (436): The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568.
So then I re-queue the build per the message/URL and...it happens again. I've Googled around but I can't seem to figure out what the issue is. I can build just fine in Visual Studio and the solution is configured for package restore. Any thoughts?
Thanks in advance.
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.
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.
We use most is Nuget restore in TFS build definition. To promote a cleaner development environment and to reduce repository size, NuGet Package Restore installs all a project's dependencies as listed in either the project file or packages.config .
Open Visual Studio, go to Tools -> NuGet Package Manager -> Package Manager Settings menu. Click Clear All NuGet Cache(s) button in options dialog then clearing process is started. Once NuGet cache location is cleared, click ok button.
If someone still having this issue on tfs build server you need to go the following:
It seems somehow after upgrading not all projects get those old block of build code removed and it's causing problems (as I understand it it's not longer needed after microsoft changed their bcl build process).
The solution to this is specified in link in the error message itself.
This is happening due to an Improvement as specified in that page:
The Improvement
We’ve updated Microsoft.Bcl.Build to use a different approach. The new version will use a conditional import similar to what NuGet’s automatic import feature does. This will always allow the project to load in Visual Studio.
However, Microsoft.Bcl.Build also adds a target to your project that will run after the build is finished. This target checks whether the current build restored packages and if so fail the build with an actionable error message:
Building a second time will fix this error. Please note that this error will only appear if packages were missing so it’s not like you always have to build twice.
Then it specifies as below for the case of build server / continuous integration (CI):
This solution doesn’t address build server / continuous integration (CI) scenarios. In order to successfully use package restore on the build server, you have two options:
- Check-in the .targets file.
- Explicitly run NuGet package restore prior to building your project/solution.
So, I suppose for your issue resolution the above two steps should be followed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With