0
votes

I'm trying to restore a NuGet package from an Azure Devops Artifact to my local installation as part of a gulpfile script.

However, I'm getting a

Response status code does not indicate success: 401 (Unauthorized).

with:

Unable to load the service index for source https://my-visualstudio-dot-com-npm-feed-here

I've tried creating a nugetauth.npmrc file with the following content:

registry=https://my-visualstudio-dot-com-npm-feed-here
always-auth=true

I then run:

vsts-npm-auth -config nugetauth.npmrc

to generate my new .npmrc file, which I then place in the same directory as my package.json and gulpfile.js files.

When I subsequently run my 'Nuget-restore' task from task runner (with "gulp-nuget-restore": "^0.7.0"), it's failing to authenticate to my feed. What am I missing?

3

3 Answers

1
votes

If you want install NuGet package from azure devops artifacts, you should add a nuget.config file to your project, in the same folder as your .csproj or .sln file. Please check this document for more information. Then you can use nuget restore task

enter image description here

If it is a npm package, you should use npm install task.

If you are using the feed from azure devops pipeline. You also need to check if your project build service account have the reader permission to this feed. Please check below steps.

Click the Feed Setting(the gear icon)--> go to Permissions --> Check if group {projectName} build service(OrganizationName) has the permission(Click add groups to add your project build service account if not already existed).

enter image description here

0
votes

Please refer to 'npm' task in ADO - https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/package/npm?view=azure-devops to install and publish npm packages. Hope this helps

0
votes

We actually found two ways of resolving this in the end.

One was to use the gulp-nuget task instead, to download a specific version of Nuget.exe (5.0.2) which would then allow us to subsequently run the restore (as I believe that version of Nuget uses the credential provider by default).

The other (which we ended up going with) was to add

overrideParams.push('/p:NuGetInteractive=true')

to the msbuild task. This will prompt users to log in if not authenticated.