Reputation: 41
I have created a build pipeline in Azure DevOps to build a .NET 8.0 application. The code resides in my Azure DevOps repository. I have selecteed the .NET Core template in classic editor to build the pipeline. My Pipeline stops at the 'Restore' task with an error :
error NU1301: Unable to load the service index for source
https://pkgs.dev.azure.com/myprojectname/_packaging/1199d650-e459-4ff6-85b8-91354ce28542/nuget/v3/index.json.
I have created an artifact feed in Azure DevOps which has all necessary NuGet packages installed. The build agent is a Microsoft hosted agent (windows OS) that tries to hit the URL and gets the error.
Can anyone help me fix this? Thank you
Tried adding other NuGet tasks like NuGet authentication, tool installer and NuGet restore but still facing the same error.
Upvotes: 3
Views: 10299
Reputation: 550
What worked for me was doing all that wade zhou said
plus adding the Build service accounts under the Build Administrator permission group.
Upvotes: 0
Reputation: 8468
I have selected the .NET Core template in classic editor to build the pipeline. My Pipeline stops at the 'Restore' task with an error.
The error NU1301: Unable to load the service index for source
is caused by the identity
doesn't have permission on the target DevOps feed.
Go to the target feed -> Permissions
tab, make sure the identity has granted the contributor
(at least reader
) permission.
The identity
could be different based on your project configuration. Details below:
If you use nuget.config in the restore task, and configure user inside nuget.config, grant the permission for the account.
If you don't use nuget.config in the restore task, check the project settings -> Limit job authorization scope to current project for non-release pipelines
:
If the option is on, you need grant feed permission for project scoped identity({Project Name} Build Service ({Org Name})
).
If the option is off, which means it used collection scoped identity(Project Collection Build Service ({OrgName})
), grant feed permission for this account.
You can check the official doc Scoped build identities for the details.
After you grant the permission for the correct
identity, it should restore successfully.
In addition, as per the feed link in the error, it's organization level
feed, it's not myprojectname
but myorganizationname
. If it's project level feed, the url has structure({org}/{project}) in url, like https://pkgs.dev.azure.com/{org}/{project}/_packaging/{feedname}/nuget/v3/index.json"
.
Upvotes: 5