【问题标题】:Unable to load the service index for source无法加载源的服务索引
【发布时间】:2020-07-21 09:23:50
【问题描述】:

我在用于 .net core 3.1 解决方案的本地 Devops 2019 构建服务器上遇到未经授权的错误。尽管这适用于其他解决方案,但构建服务器似乎无法访问工件提要。这是错误:

Active code page: 65001
[command]"C:\Program Files\dotnet\dotnet.exe" test C:\a\_work\61\s\MySolution\MySolution.csproj --logger trx --results-directory C:\a\_work\_temp
C:\Program Files\dotnet\sdk\3.1.302\NuGet.targets(128,5): error : Unable to load the service index for source https://mydomin/tfs/DefaultCollection/_packaging/MyFeed/nuget/v3/index.json. [C:\a\_work\61\MySolution\MySolution.csproj]
C:\Program Files\dotnet\sdk\3.1.302\NuGet.targets(128,5): error :   Response status code does not indicate success: 401 (Unauthorized). [C:\a\_work\61\s\MySolution\MySolution.csproj]

这里是pipeline.yaml文件,错误发生在DotNetCoreCLI@2步骤:

# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core

trigger:
- master

pool: 'Default'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1
  inputs:
    versionSpec: '5.x'

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: DotNetCoreCLI@2
  inputs:
    command: 'publish'
    publishWebProjects: true
    arguments: '--configuration $(buildConfiguration) --self-contained true  -f netcoreapp3.1 -r win10-x64 --output $(Build.ArtifactStagingDirectory)' 

- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'drop'
    publishLocation: 'Container'

对如何解决身份验证问题有任何建议吗?

我尝试在构建服务器上更新工件提要的 PAT 令牌,但没有成功。 以下是完整的错误信息:

##[section]Starting: DotNetCoreCLI
==============================================================================
Task         : .NET Core
Description  : Build, test, package, or publish a dotnet application, or run a custom dotnet command
Version      : 2.153.3
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli
==============================================================================
[command]C:\Windows\system32\chcp.com 65001
Active code page: 65001
[command]"C:\Program Files\dotnet\dotnet.exe" publish C:\a\_work\588\s\MySolution.sln --configuration Release --self-contained true -f netcoreapp3.1 -r win10-x64 --output C:\a\_work\588\a\s
Microsoft (R) Build Engine version 16.5.0+d4cbfca49 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 292,84 ms for C:\a\_work\588\s\MySolution\MySolution.csproj.
C:\Program Files\dotnet\sdk\3.1.201\NuGet.targets(124,5): error : Unable to load the service index for source https://MyDomain/tfs/DefaultCollection/_packaging/MyFeed/nuget/v3/index.json. [C:\a\_work\588\s\MySolution.sln]
C:\Program Files\dotnet\sdk\3.1.201\NuGet.targets(124,5): error :   Response status code does not indicate success: 401 (Unauthorized). [C:\a\_work\588\s\MySolution.sln]
##[error]Error: The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 1
##[error]Dotnet command failed with non-zero exit code on the following projects : C:\a\_work\588\s\MySolution.sln
##[section]Finishing: DotNetCoreCLI

【问题讨论】:

    标签: c# .net-core azure-devops


    【解决方案1】:

    请尝试在 DevOps 中create a PAT,并通过以下命令使用个人访问令牌注册包源:

    nuget sources add -name {your feed name} -source {your feed URL} -username {anything} -password {your PAT}

    【讨论】:

    • 嗨@CeceDong 感谢您的建议。我使用命令更新了构建服务器上的源代码,但构建仍然失败并出现相同的身份验证错误。请查看问题中更新的错误详细信息。还有其他建议吗?
    • 尝试将system.debug设置为true,看看是否还有更多信息。另外,尝试在提要中授予构建代理帐户Contributor 权限。
    • 我向构建代理授予了贡献者权限并设置了调试标志,但没有看到任何可能与该问题相关的内容。我想知道这是否与一般的.net核心有关。找到了这个github.com/dotnet/aspnetcore/issues/24013,但不确定它是否是同一个问题。还有其他建议吗?
    • 您是否在构建代理机器上检查过%appdata%\NuGet\nuget.config?有``信息吗?
    • NuGet Authenticate 任务是从管道对 Artifacts 提要进行身份验证的最新推荐方法,但它在 Devops 2019 中不存在。请查看以下链接中的解决方法,看看它是否对您有帮助:@ 987654323@
    猜你喜欢
    • 2018-11-29
    • 2018-09-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-12
    • 1970-01-01
    相关资源
    最近更新 更多