Home > Software engineering >  Azure Pipeline Cant Access Azure Artefact Nuget Project Feed Even With Correct Permissions And Nuget
Azure Pipeline Cant Access Azure Artefact Nuget Project Feed Even With Correct Permissions And Nuget

Time:07-11

I have a really strange issue where I have a project based nuget feed which one pipeline publishes to, which works fine, then another pipeline which needs to restore a project which uses this nuget feed.

The problem is I have followed all the instructions on this such as:

  • Make sure Build Service has permissions
  • Make sure NuGetAuthenticate 0 or 1 is called
  • Ensure there is a nuget.config with the feed included

So for example the nuget.config looks like:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <clear />
    <add key="nuget" value="https://api.nuget.org/v3/index.json" />
    <add key="azure-feed" value="http://pkgs.dev.azure.com/<org>/<project>/_packaging/<feed-name>/nuget/v3/index.json" />
  </packageSources>
</configuration>

Then the pipeline section looks like:

steps:
  - task: NuGetAuthenticate@0
  - task: DotNetCoreCLI@2
    displayName: dotnet restore
    inputs:
      command: restore
      nugetConfigPath: 'nuget.config'
      feedsToUse: config

This all works fine in the IDE (VS and Rider) and the pipelines that publish and read the nuget package are all in the same azure devops project as the feed.

When the build runs I see the authenticate step run:

Setting up the credential provider to use the identity '<project> Build Service (<org>)' for feeds in your organization/collection starting with:
  https://pkgs.dev.azure.com/<org>/
  https://<org>.pkgs.visualstudio.com/

Which is all correct and is pointing to the correct feeds, but when the restore runs the error below occurs:

error NU1301: Unable to load the service index for source http://pkgs.dev.azure.com/<org>/<project>/_packaging/<feed-name>/nuget/v3/index.json.

All the articles online say to try switching to NuGetAuthenticate@0 or enabling higher level settings to allow build service project scopes to not be constrained, as well as confirming all permissions are correct, none of that has solved the problem.

CodePudding user response:

The issue here is that the feed in the nuget.config file is using http not https and for some reason the nuget authenticate task will ONLY authenticate the https url not the unsecure http one which the IDEs work fine with.

So changing:

<add key="azure-feed" value="http://pkgs.dev.azure.com/<org>/<project>/_packaging/<feed-name>/nuget/v3/index.json" />

to:

<add key="azure-feed" value="https://pkgs.dev.azure.com/<org>/<project>/_packaging/<feed-name>/nuget/v3/index.json" />

Fixes it all and it works, this was never mentioned as a possible solution online so I thought it prudent to put here for any future generations who have the same issue.

  • Related