JJJCoder
JJJCoder

Reputation: 16946

Azure Pipeline Consuming Azure Artifact Nuget - NU1301: Unable to load the service index for source https://pkgs.dev.azure.com/... (Q&A)

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

Answers (1)

JJJCoder
JJJCoder

Reputation: 16946

After a lot of trial and error, this seemed to be the fix:

  1. 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.

  2. 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.

  3. 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

Related Questions