'Response status code does not indicate success: 401 in the task "restore" on the azure-pipeline
I have the following error:
error : Unable to load the service index for source https://privateLibrary.com/private/_packaging/privateOrganitation/nuget/v3/index.json. [/home/vsts/work/1/s/Local.Proyect.Core/Local.Proyect.Core.csproj]
/usr/share/dotnet/sdk/3.0.101/NuGet.targets(123,5):
error : Response status code does not indicate success: 401 (Unauthorized). [/home/vsts/work/1/s/Local.Proyect.Core/Local.Proyect.Core.csproj]
My azure-pipeline.yml:
variables:
buildConfiguration: 'Release'
localProyectName: 'Local.Proyect.Core'
localProyectCoreDirectory: './Local.Proyect.Core'
trigger:
branches:
include:
- master
steps:
- task: UseDotNet@2
inputs:
packageType: 'sdk'
- task: DotNetCoreCLI@2
displayName: 'dotnet restore'
inputs:
command: restore
projects: '**/$(localProyectName).csproj'
feedsToUse: config
nugetConfigPath: $(localProyectCoreDirectory)/NuGet.Config
arguments: --force
- task: DotNetCoreCLI@2
displayName: 'Build All'
inputs:
projects: '**/$(localProyectName).csproj'
arguments: '--no-restore --configuration $(buildConfiguration)'
- script: dotnet publish --configuration $(buildConfiguration) --output $(Build.ArtifactStagingDirectory)/$(localProyectName) ./$(localProyectName)/$(localProyectName).csproj
displayName: 'dotnet publish of project $(localProyectName)'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: $(localProyectName)'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/$(localProyectName)'
ArtifactName: '$(localProyectName)'
The error start in command restore. As you can see in azure devops machine can´t restore mi private packets. I am using the NuGet.Config inside my app "Local.Proyect.Core" with the URL of the organitation:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<packageSources>
<add key="privateOrgnitation" value="https://privateLibrary.com/private/_packaging/privateOrganitation/nuget/v3/index.json." />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
<bindingRedirects>
<add key="skip" value="False" />
</bindingRedirects>
<packageManagement>
<add key="format" value="0" />
<add key="disabled" value="False" />
</packageManagement>
</configuration>
Why the machine can´t find my Azure Artifacts in OTHER organitation?? And why I haven't got any error in visual studio and here yes...
Solution 1:[1]
Okey, after wait a long time away since I have had this problem, I resolved this with an internal organization of my code and the NuGet packages artifacts. The problem was that in devops my packages were in a different organization and it was a private repository. So, now when the azure machine needs a artifact, nuget can take it and use to build my project.
Solution 2:[2]
Response status code does not indicate success: 401 in the task “restore” on the azure-pipeline
According to the error info:
Response status code does not indicate success: 401 (Unauthorized)
It seems you are not provide the credentials for a package source in nuget.config, you can try to provide the credential in the nuget.config, like:
<packageSourceCredentials>
<privateOrgnitation>
<add key="Username" value="[email protected]" />
<add key="ClearTextPassword" value="YourPassword" />
</privateOrgnitation>
</packageSourceCredentials>
Check the document packageSourceCredentials for some more details.
Hope this helps.
Solution 3:[3]
This problem can also occur if your password has changed.
Reset your cached credentials via the Credentials Manager in Windows: Control Panel ? All Control Panel Items ? Credential Manager. Below Windows Credentials remove any entry with a name like VSCredentials_<domain>.
Then try building again; Visual Studio should ask for your current password.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Vahid Farahmandian |
| Solution 2 | Leo Liu-MSFT |
| Solution 3 | Michel de Ruiter |
