C# 无法加载源的服务索引
我在.net core 3.1解决方案的内部部署Devops 2019构建服务器上遇到未经授权的错误。构建服务器似乎无法访问工件提要,尽管这适用于其他解决方案。以下是错误:C# 无法加载源的服务索引,c#,.net-core,azure-devops,C#,.net Core,Azure Devops,我在.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
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
请尝试在DevOps中注册,并通过以下命令使用个人访问令牌注册package feed:
nuget sources add-name{your feed name}-source{your feed URL}-username{anything}-password{your PAT}
Hi@CeceDong感谢您的建议。我用命令更新了构建服务器上的源代码,但构建仍然失败,出现了相同的身份验证错误。请参阅问题中更新的错误详细信息。还有其他建议吗?请尝试将system.debug设置为true,以查看是否有更多消息。另外,尝试在提要中授予生成代理帐户Contributor
权限。我向生成代理授予了Contributor权限并设置了调试标志,但没有看到任何与问题相关的内容。我想知道这是否与.NETCore有关。发现此问题,但不确定是否是同一问题。还有其他建议吗?您是否在生成代理计算机上检查了%appdata%\NuGet\NuGet.config
?有``信息吗?NuGet Authenticate任务是最新推荐的对来自管道的工件提要进行身份验证的方法,但它在Devops 2019中不存在。请检查以下链接中的解决方法,以查看它是否有助于您: