24

Updated 20-Feb-2020

Summary

Azure DevOps pipeline build not able to find NuGet package from our private feed under Artifacts.

Our Azure DevOps environment

In Azure, we have our company "space": dev.azure.com/OurCompany

Under that, we have multiple Projects, so for example, imagine these three:

  • Green: this holds applications of a certain type
  • Blue: this holds applications of a different type
  • Red: this holds our "common" helper code

RED

RED holds all our common helper code are DLLs consumed by applications in GREEN and BLUE. These are made available as NuGet packages.

Under RED's Artifacts, we see an "organisational scoped feed" called "OurCompany". We understood that we couldn't use this because these NuGet packages need to be available to everyone in OurCompany, which means not only on Azure, but also on our DeskTop machines in our Corporate network (where we run Visual Studio). The "organisational scoped feed" I don't think is exposed to our Corporate Network.

We therefore created a new Feed under RED's Artifacts. When I view Permissions, I see the following entries:

  • {me} : (Owner)
  • [OurCompany]\Project Collection Adminstrators : (Owner)
  • [RED]\Project Administrators : (Owner)
  • RED Build Service (OurCompany) : (Contributor)
  • Project Collection Build Service (OurCompany) : (Contributor)
  • [RED]\Contributors (Contributor)

Corporate

So, back in Corporate, we add the NuGet package feed to our Visual Studio and it can then pull the NuGet packages down from Azure.

GREEN and BLUE

In here we have our products. We create a build Pipeline and we add a NuGet restore step:

- task: NuGetCommand@2
  displayName: 'Restore for Our Application'
  inputs:
    command: 'restore'
    restoreSolution: '**/*.sln'
    feedsToUse: 'select'
    vstsFeed: '{Guid1}/{Guid2}'

The two Guids were filled in when we picket the Azure Artifacts feed from the drop-down.

GREEN or BLUE NuGet Restore Failure

So this is where we run into our issue. When the NuGet restore step executes, it fails with the following message:

Unable to find version 'nnnn.n.n' of package 'TheNuGetPackage'.

The log output is vast, but the salient lines appear to be:

2020-02-18T18:36:35.2838118Z [command]C:\hostedtoolcache\windows\NuGet\5.4.0\x64\nuget.exe sources Add -NonInteractive -Name {Guid2} -Source https://pkgs.dev.azure.com/OurCompany/{Guid1}/_packaging/{Guid2}/nuget/v3/index.json
-ConfigFile d:\a\1\Nuget\tempNuGet_356.config 2020-02-18T18:36:35.7513495Z Package source with Name: {Guid2} added successfully. 2020-02-18T18:36:41.1671856Z     [CredentialProvider.183638]Command-line v0.1.20+a5d37185a1a95acb4f0g997b9c23cab99508: "d:\a\_tasks\NuGetCommand_333b11bd-d341-40d9-bdbd-b32d5ce6f23b\2.164.0\CredentialProviderV2\plugins\netfx\CredentialProvider.Microsoft\CredentialProvider.Microsoft.exe"
-Plugin 2020-02-18T18:36:41.1673979Z     [CredentialProvider]Handling 'Request' 'GetAuthenticationCredentials'. Time elapsed in ms: 3 - Payload: {"Uri":"https://pkgs.dev.azure.com/OurCompany/{Guid1}/_packaging/{Guid2}/nuget/v3/index.json","IsRetry":false,"IsNonInteractive":true,"CanShowDialog":true} 2020-02-18T18:36:41.1674299Z     [CredentialProvider]Handling auth request, Uri: https://pkgs.dev.azure.com/OurCompany/{Guid1}/_packaging/{Guid2}/nuget/v3/index.json, IsRetry: False, IsNonInteractive: True, CanShowDialog: True 2020-02-18T18:36:41.1674465Z     [CredentialProvider]URI: https://pkgs.dev.azure.com/OurCompany/{Guid1}/_packaging/{Guid2}/nuget/v3/index.json 2020-02-18T18:36:41.1674818Z     [CredentialProvider]Skipping NuGetCredentialProvider.CredentialProviders.VstsBuildTaskServiceEndpoint.VstsBuildTaskServiceEndpointCredentialProvider, cannot provide credentials for https://pkgs.dev.azure.com/OurCompany/{Guid1}/_packaging/{Guid2}/nuget/v3/index.json 2020-02-18T18:36:41.1675261Z     [CredentialProvider]VstsBuildTaskCredentialProvider - https://dev.azure.com/OurCompany/ 2020-02-18T18:36:41.1675425Z     [CredentialProvider]VstsBuildTaskCredentialProvider - https://pkgs.dev.azure.com/OurCompany/ 2020-02-18T18:36:41.1675722Z    [CredentialProvider]VstsBuildTaskCredentialProvider - https://pkgs.dev.azure.com/OurCompany/ 2020-02-18T18:36:41.1676021Z    [CredentialProvider]VstsBuildTaskCredentialProvider - https://pkgs.dev.azure.com/OurCompany/ 2020-02-18T18:36:41.1676161Z    [CredentialProvider]VstsBuildTaskCredentialProvider - Matched prefix: https://pkgs.dev.azure.com/OurCompany/ 2020-02-18T18:36:41.1676330Z    [CredentialProvider]VstsBuildTaskCredentialProvider - Found credentials for endpoint https://pkgs.dev.azure.com/OurCompany/{Guid1}/_packaging/{Guid2}/nuget/v3/index.json 2020-02-18T18:36:41.1680820Z   https://pkgs.dev.azure.com/OurCompany/{Guid1}/_packaging/{Guid2}/nuget/v3/index.json: Unable to load the service index for source https://pkgs.dev.azure.com/OurCompany/{Guid1}/_packaging/{Guid2}/nuget/v3/index.json. 2020-02-18T18:36:41.1680996Z   Response status code does not indicate success: 404 (Not Found - VS800075: The project with id 'vstfs:///Classification/TeamProject/{Guid1}' does not exist, or you do not have permission to access it. (DevOps Activity ID: 0628EDE7-6E7E-465D-A6AE-7B6B0AA065D2)).

This looks like a permissions thing to me. But what seems odd is that the Artifact Feed in RED was discoverable when creating the Pipeline Build YAML when we then don't have permissions to use it.

I did try adding permissions to the Feed in RED. Clicking on the "Add users/groups". I found the following and added them as either Reader or Contributor, but with no success.

  1. [GREEN]\ Green Team
  2. GREEN Build Services

So:

  1. Am I going about this the wrong way? If so, what ought I be doing (I thought I'd followed the Azure DevOps instructions fairly closely)
  2. Am I going about this the right way? If so, what have I missed?

Update #1

Verbose error message from Restore step

https://api.nuget.org/v3/index.json: Package 'Package1.nnnn.n.n' is not found on source 'https://api.nuget.org/v3/index.json'.
https://pkgs.dev.azure.com/OurCompany/{Guid1}/_packaging/{Guid2}/nuget/v3/index.json: Unable to load the service index for source https://pkgs.dev.azure.com/OurCompany/{Guid1}/_packaging/{Guid2}/nuget/v3/index.json. Response status code does not indicate success: 404 (Not Found - VS800075: The project with id 'vstfs:///Classification/TeamProject/{Guid1}' does not exist, or you do not have permission to access it. (DevOps Activity ID: {Guid})).

DrGriff
  • 4,394
  • 9
  • 43
  • 92
  • It's been noted that you [cross-posted this question](https://devops.stackexchange.com/questions/10843/project-pipeline-not-able-to-access-nuget-package-from-artifact-feed-in-differen). Since it was well received here (upvoted, answered), I'm not going to delete this copy, but [as per the general rules of the Stack Exchange network](https://meta.stackexchange.com/q/64068) you should really *delete the old post*. – Martijn Pieters Mar 06 '20 at 19:53
  • the question was FIRST posted on DevOps.SE, so the SO version is the cross-post ... (and should be deleted or migrated). – Pierre.Vriens Mar 08 '20 at 08:55

4 Answers4

46

Finally, I found the problem. I wonder if this is a bug, or just poorly documented....(or maybe I just didn't interpret it correctly).

As per Leo Lui-MSFT's suggestion above (documented by Microsoft), I'd added the permissions to the NuGet feed, and this didn't work. However, I was intrigued by his sentence:

If you've changed your builds to run at project scope

Personally, I hadn't, so I got with our System Administrator and we went through all the possible settings. Eventually, we found it - it wasn't something I had the ability to change.

So in my example above, BLUE and GREEN are the two projects that are trying to use the NuGet package in RED's Artifact feed.

So picking BLUE (or GREEN), in the bottom left hand corner of Azure DevOps you'll see a link "Project Settings". Under "Pipelines > Settings" there are four settings. We had to change the following to be:

Limit job authorization scope to current project = false

Hope that helps!

DrGriff
  • 4,394
  • 9
  • 43
  • 92
  • This was exactly what I needed. We had two other projects that were already doing this, but I couldn't figure out what was missing from the configuration on our new project. Thanks for posting here. – Macros185 Apr 22 '20 at 00:33
  • 3
    Hero. What an awful setting in an awful place! – James Law May 13 '20 at 16:39
  • Thanks for finding this. Hopefully MS finds a way to make this very common task easier. –  May 20 '20 at 00:31
  • This works. Not sure why all the feeds are project scope. We had some feeds that are org scope and they work fine. I can't tell you how many thanks! – Joe Jun 15 '20 at 16:58
  • You drop manna in the way of the hungry. I found this setting and since I couldn't change it thought I was looking in the wrong place. This post confirmed that it is correct and I found that it's changed at the organization level for unreleased feeds. Changed it and now builds are working fine. Thanks for this – Fabulous Oct 14 '20 at 15:05
  • Damn, I lost too much time on this! Many thanks for this post! – ITD Nov 03 '20 at 14:20
  • You made my day! Thank you! – etalon11 Apr 08 '21 at 13:04
  • This didn't work for me. – user3038723 May 17 '22 at 20:16
9

Azure DevOps Project pipeline not able to access Artifact Feed in different project

I think you are going the right ways. There is known issue about the project scope feed.

As the document Package permissions in Azure Pipelines stated:

To use packages from a feed in Azure Pipelines, the appropriate build identity must have permission to your feed. By default, the Project Collection Build Service is a Contributor. If you've changed your builds to run at project scope, you'll need to add the project-level build identity as a Reader or Contributor, as desired. The project-level build identity is named as follows:

[Project name] Build Service ([Organization name]) (e.g. FabrikamFiber Build Service (codesharing-demo))

enter image description here

You could check this thread for some more details.

Hope this helps.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135
  • This seems to be how I have it set up... So "RED" is the project with the NuGet packages. As per your screen shot above I have `Project Collection Build Service (OurCompany) = Contributor` and the following entries for the Projects wanting to pull these packages: `GREEN Build Service (OurCompany) = Reader; BLUE Build Service (OutCompany) = Reader`. The Elipsis also shows those two values "Allow builds and releases" and "Allow project-scoped builds", but they're greyed out and seem to have no effect. However, those build pipelines still show `Unable to find version '.' of package '...'.` – DrGriff Feb 20 '20 at 08:45
  • Lui-MSFT: I updated the original post with the error message from the NuGet restore step. Does that shed any further light? – DrGriff Feb 20 '20 at 09:48
  • One thing I just noticed. For the build step`NuGetCommand@2` it has: `vstsFeed: '{Guid1}/{Guid2}'`. I am though using an Azure Artifact that's using Git and not vsts....is that relevant? – DrGriff Feb 20 '20 at 11:16
  • @DrGriff, What you mean the `using an Azure Artifact that's using Git and not vsts`? How about the result use the UI instead of the YAML? – Leo Liu Feb 21 '20 at 11:12
  • I have the same issue. I added the build service of the consuming project to the permissions of my fead, but nothing changed. – Heinzlmaen Feb 21 '20 at 15:12
2

You can do the following to have access to other project feed in the same organization:

  1. Choose the following options from: Feed settings >> Permissions >> [Click on the three-dot menu] >> sel a) Allow build and releases b) Allow project-scoped builds
  2. Go to the project settings (from where you want to access the feed)
  3. Make sure the option is unchecked in the following setting: Project Settings >> Pipelines >> Settings >> Limit job authorization scope to current project for non-release pipelines
Meghnath Das
  • 145
  • 1
  • 6
1

In my LibsProject I have a LibsFeed (OP's RED), which I wanted to use in a pipeline in my ConsumingProject.

I had to add the following permissions to get it to work:

  • LibsFeed: Add ConsumingProject Build Service as Contributor (Read automatically changed to Contributor somehow)
  • LibsProject: Add ConsumingProject Team to the LibsProject Team under LibsProject -> Project Settings -> Team

I can not even enable OP's solution, even with all thinkable admin rights

Limit job authorization scope to current project

Heinzlmaen
  • 869
  • 10
  • 20