How to Fix Missing NuGet Packages in Azure DevOps

Last week we run into a strange problem with our build server. We use Azure DevOps with a local build machine. Everything worked as expected on Monday, yet on Tuesday without any changes on our part the CI job failed with this problem:

WARNING: Unable to find version ‘2.7.1’ of package ‘Serilog’.
WARNING: Unable to find version ‘1.50.5’ of package ‘Dapper’.

Our NuGet Task in the pipeline found the packages and installed them as expected:

Restoring NuGet package Dapper.1.50.5.
Restoring NuGet package Serilog.2.7.1.
Adding package ‘Serilog.2.7.1’ to folder ‘C:\agent2\_work\8\s\P*\packages’
Adding package ‘Dapper.1.50.5’ to folder ‘C:\agent2\_work\8\s\P*\packages’

The packages got installed, why can our build task not find them? We checked and re-checked every possible setting, yet our build kept failing. Not all builds, but just the builds of a single project – the other projects worked without any problems.

After a long hunt my colleague found the problem: This project modified the location of the packages folder. Instead on the default location next to the solution file this project set the packages folder one directory above. Until now the Azure DevOps pipeline worked with our nuget.config settings file that specified that location. A change somewhere behind the scenes changed that.

Luckily for us, we can specify the location of our packages folder in the NuGet task in the Advanced section:

Open the Advnced section to specify the location of your packages folder

With this setting you must make sure that your build task does not try to restore NuGet packages as well. This option is depreciated for a long time but was needed as a fallback to circumvent another bug in the build task.

Our builds are now green again and I hope you need less time than we did to fix this strange problem.

1 thought on “How to Fix Missing NuGet Packages in Azure DevOps”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.