If your setting up a CI pipleline on Azure Devops for a site which uses a NuGet feed from a source that isn't on nuget.org you may see the error:
"The nuget command failed with exit code(1) and error(Errors in packages.config projects Unable to find version..."
On your local dev machine you will have added extra an extra NuGet feed source through visual studio which will update a global file on you machine. However as Azure Pipelines is a serverless solution you don't have the same global file to update to include the sources.
Instead of this you need to add a NuGet.config file to the root of your repository.
Here is an example of one set to include Sitecores NuGet package feed.
<?xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <add key="nuget.org" value="https://www.nuget.org/api/v2/" /> <add key="Sitecore NuGet v2 Feed" value="https://sitecore.myget.org/F/sc-packages/" /> </packageSources> </configuration>
Next you will need to update your pipeline to tell the NuGet step to use this config file
- task: NuGetCommand@2 inputs: restoreSolution: '$(solution)' feedsToUse: 'config' nugetConfigPath: 'NuGet.config'
And that's it. As long as all the sources are correct the NuGet command should now find your packages.