microsoft / azure-pipelines-agent

Azure Pipelines Agent 🚀
MIT License
1.71k stars 861 forks source link

[BUG]: recent windows-2022 update causes build failure - Error : Unable to load the service index for source #4556

Open Andrew-George-LG opened 8 months ago

Andrew-George-LG commented 8 months ago

What happened?

All our build pipelines now fail on the 'dotnet build' step with a 401 Unauthorised error. They all began failing at the same time (a few days ago), and had not been altered in any way.

They only fail on the windows-2022 build agent image. windows-2019 is fine.

The full error is :

Error : Unable to load the service index for source https://.pkgs.visualstudio.com/_packaging//nuget/v3/index.json. Response status code does not indicate success: 401 (Unauthorized).

A previous 'dotnet restore' command works fine, so the feed can be accessed by the pipeline.

link to Stack Overflow error reported by someone else : https://stackoverflow.com/a/77530565

Versions

Agent name: 'Hosted Agent' Current agent version: '3.230.2'

Operating System Microsoft Windows Server 2022 10.0.20348 Datacenter

MSBuild version 17.8.3+195e7f5a3 for .NET

Environment type (Please select at least one enviroment where you face this issue)

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

No response

Version controll system

No response

Relevant log output

MSBuild version 17.8.3+195e7f5a3 for .NET
  Determining projects to restore...

##[error]C:\Program Files\dotnet\sdk\8.0.100\NuGet.targets(156,5): Error : Unable to load the service index for source https://<org>.pkgs.visualstudio.com/_packaging/<feed>/nuget/v3/index.json.

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

C:\Program Files\dotnet\sdk\8.0.100\NuGet.targets(156,5): error : Unable to load the service index for source https://<org>.pkgs.visualstudio.com/_packaging/<feed>/nuget/v3/index.json. [D:\a\1\s\<folder>\<solution>.sln]

C:\Program Files\dotnet\sdk\8.0.100\NuGet.targets(156,5): error :   Response status code does not indicate success: 401 (Unauthorized). [D:\a\1\s\<folder>\<solution>.sln]

Build FAILED.
DenisNikulin5 commented 8 months ago

Hi @Andrew-George-LG thanks for reporting! We are working on more prioritized issues at the moment, but will get back to this one soon.

zappod commented 7 months ago

Are there any work arounds for this? At the moment I can't build my pipelines and that's kind of a big issue...

cosminvladutu commented 5 months ago

Try --no-restore argument to your build task. For us, it worked. Story: We had a restore step and after that a build step. On the build step, we got the same error. On the build step we added no-restore and it seems it is working.

fabricioferreira commented 4 months ago

This problem suddenly started happening once I upgraded my app from Net7 to Net8.

I solved it by changing the .Net version used to run the dotnet tool install command:


# initial setup/config...

steps:
  - task: UseDotNet@2
    displayName: Use Net6
    inputs:
      version: 6.x

  - powershell: |
      dotnet tool install JetBrains.dotCover.GlobalTool -g --ignore-failed-sources
    displayName: Setup dotCover CLI

  - task: UseDotNet@2
    displayName: Use Net8
    inputs:
      version: 8.x

 # additional tasks ... 
`
CraigComeOnThisNameCantBeTaken commented 1 month ago

@fabricioferreira Thank you for the workaround