gpt4 book ai didi

azure-devops - 启用自包含导致 dotnet 发布失败并使用私有(private) NuGet

转载 作者:行者123 更新时间:2023-12-05 00:45:26 26 4
gpt4 key购买 nike

使用私有(private) NuGet 源进行身份验证时,启用独立发布会导致错误。没有“--self-contained true”,一切运行正常,出现以下错误。
我能做些什么来解决这个问题?

##[section]Starting: Publish
==============================================================================
Task : .NET Core
Description : Build, test, package, or publish a dotnet application, or run a custom dotnet command
Version : 2.154.6
Author : Microsoft Corporation
Help : [Learn more about this task](https://go.microsoft.com/fwlink/?linkid=832194) or [see the .NET Core documentation](https://docs.microsoft.com/dotnet/core/)
==============================================================================
[command]C:\Windows\system32\chcp.com 65001
Active code page: 65001
[command]C:\agent\_work\_tool\dotnet\dotnet.exe publish C:\agent\_work\195\s\redacted.csproj --self-contained true --runtime win-x64 --configuration release --output C:\agent\_work\195\a\redacted
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

Restoring packages for C:\agent\_work\195\s\redacted.csproj...
Restore completed in 40.71 ms for C:\agent\_work\195\s\redacted.csproj.
Restore completed in 0.51 ms for C:\agent\_work\195\s\redacted.csproj.
Restore completed in 1.17 ms for C:\agent\_work\195\s\redacted.csproj.
Restoring packages for C:\agent\_work\195\s\redacted.csproj...
C:\agent\_work\_tool\dotnet\sdk\2.2.105\NuGet.targets(114,5): error : Unable to load the service index for source https://pkgs.dev.azure.com/redacted/_packaging/redacted/nuget/v3/index.json. [C:\agent\_work\195\s\redacted.csproj]
C:\agent\_work\_tool\dotnet\sdk\2.2.105\NuGet.targets(114,5): error : Response status code does not indicate success: 401 (Unauthorized). [C:\agent\_work\195\s\redacted.csproj]
##[error]Error: The process 'C:\agent\_work\_tool\dotnet\dotnet.exe' failed with exit code 1
##[error]Dotnet command failed with non-zero exit code on the following projects : C:\agent\_work\195\s\redacted.csproj
##[section]Finishing: Publish

最佳答案

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


此错误是由于在 Azure Devops 中,对 VSTS 源进行身份验证,Dotnet.exe 仅支持 dotnet restoredotnet nuget push命令。所以,尝试运行 dotnet restore先做任务。
更新:
由于您已经执行了 dotnet restore运行前 dotnet publish .身份验证问题应该是由 dotnet publish 引起的。任务。当你执行 --self-contained true ,这意味着除了您在本地拥有的默认文件外,它还会尝试从其他路径获取文件,包括您的私有(private)提要。要访问私有(private)提要,它需要凭据。如果没有凭证,私有(private)提要将拒绝获取请求。然后,它可能会导致此错误。
还有,dotnet publish包括 隐式 restore步骤,但不会有系统凭据。因此,即使您在前面的步骤中成功运行了 dotnet restore,它也可能因未验证而失败,因为在上一个任务完成后会清除凭据。
您可以添加 --no-restore到参数以避免隐式恢复。更多详细信息,请查看此文档: implicit restore that runs during publish .

关于azure-devops - 启用自包含导致 dotnet 发布失败并使用私有(private) NuGet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57253798/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com