Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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...

like image 896
Marin Avatar asked Nov 06 '22 11:11

Marin


1 Answers

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.

like image 73
Marin Avatar answered Nov 12 '22 16:11

Marin