Reputation: 16946
I am trying to have my Azure Pipeline get Nuget Packages from my Azure Artifacts feed, but they don't want to talk to each other.
I have followed this document and '[Project name] Build Service ([Organization name])'
already seems to have rights, but I'm getting the following error.
##[error]The nuget command failed with exit code(1) and error(NU1301: Unable to load the service index for source https://pkgs.dev.azure.com/.../.../nuget/v3/index.json.
My build is unchanged from before.
What should I do? (Q&A Below)
Upvotes: 1
Views: 1096
Reputation: 16946
After a lot of trial and error, this seemed to be the fix:
Go to Artifacts > your artifact feed > 'Connect to feed' > Nuget.exe and copy the nuget config. Create a file called nuget.config
at the same level as the sln (could be csproj level) and paste in the contents.
In Artifacts (Artifacts > Settings Cog > Permissions) You need {project name} Build Service ({organization name})
AND Project Collection Build Service ({organization name})
to have at least 'Collaborator' (you can have contributor) rights as documented here.
In the build, two additional steps were required (might need to overwrite the existing nuget installer). I found this that referenced the Nuget Authenticate, and I also needed to install the Azure Artifacts Provider. Start of the build shown below (was previously just the NugetToolInstaller step).
steps:
- task: NuGetToolInstaller@1
# Required for custom access to Artifacts
- task: PowerShell@2
displayName: "Install Artifacts Provider"
inputs:
targetType: 'inline'
script: |
Write-Host "Install Artifacts Provider"
Invoke-Expression "& { $(irm https://aka.ms/install-artifacts-credprovider.ps1) } -AddNetfx"
# Check we can authenticate
- task: NuGetAuthenticate@1
displayName: "Nuget Authentication"
Upvotes: 3