Background
We regularly re-build our Azure DevOps private agents using Packer and Lability, as I have posted about before.
Since the latest re-build, we have seen all sorts of problems. All related to pulling packages and tools from NuGet based repositories. Problems we have never seen with any previous generation of our agents.
The Issue
The issue turned out to be related to registering a private PowerShell repository.
$RegisterSplat = @{
Name = 'PrivateRepo'
SourceLocation = 'https://psgallery.mydomain.co.uk/nuget/PowerShell'
PublishLocation = 'https://psgallery.mydomain.co.uk/nuget/PowerShell'
InstallationPolicy = 'Trusted'
}
Register-PSRepository @RegisterSplat
Running this command caused the default dotnet NuGet repository to be unregistered i.e. the command dotnet nuget list source was expected to return
Registered Sources:
1. PrivateRepo
https://psgallery.mydomain.co.uk/nuget/Nuget
2. nuget.org [Enabled]
https://www.nuget.org/api/v2/
3. Microsoft Visual Studio Offline Packages [Enabled]
C:Program Files (x86)Microsoft SDKsNuGetPackages
But it returned
Registered Sources:
1. PrivateRepo
https://psgallery.mydomain.co.uk/nuget/Nuget
2. Microsoft Visual Studio Offline Packages [Enabled]
C:Program Files (x86)Microsoft SDKsNuGetPackages
The Workaround
You can’t call this a solution, as I cannot see why it is really needed, but the following command does fix the problem
dotnet nuget add source https://api.nuget.org/v3/index.json -n nuget.org