启用自包含功能会导致dotnet发布因私有NuGet而失败

编程入门 行业动态 更新时间:2024-10-14 16:24:07
本文介绍了启用自包含功能会导致dotnet发布因私有NuGet而失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

启用独立的发布会导致在使用私有NuGet feed进行身份验证时发生错误.没有"--self-contained true",一切运行正常,出现以下错误.我该怎么办才能解决这个问题?

Enabling a self-contained publish causes an error when authenticating with a private NuGet feed. Without "--self-contained true" everything runs fine, with it the error below appears. What can I do to resolve this?

##[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](go.microsoft/fwlink/?linkid=832194) or [see the .NET Core documentation](docs.microsoft/dotnet/core/) ============================================================================== [command]C:\Windows\system32\chcp 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 pkgs.dev.azure/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

推荐答案

错误:响应状态代码未指示成功:401(未经授权).

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

此错误是由Azure Devops中的错误导致的,为了对VSTS feed进行身份验证,Dotnet.exe仅支持 dotnet restore 和 dotnet nuget push 命令.因此,请先尝试运行 dotnet restore 任务.

This error caused by that in Azure Devops, for authenticate to VSTS feed, the Dotnet.exe only support dotnet restore and dotnet nuget push commands. So, try with running dotnet restore task first.

更新:

由于您已经在运行 dotnet发布之前执行了 dotnet还原.身份验证问题应由 dotnet publish 任务引起.当您执行-self-contained true 时,这意味着除了本地拥有的默认文件之外,它还会尝试从其他路径(包括您的私人供稿)中获取文件.要访问私人供稿,它需要凭据.如果没有凭据,则私有供稿将拒绝获取请求.然后,可能会导致此错误.

Since you have executed the dotnet restore before running dotnet publish. The auth issue should caused by the dotnet publish task. While you execute --self-contained true, this means that except the default files which you have locally, it also try to get files from the other path include your private feed. For accessing private feed, it needs credential. If without credential, the private feed will refuse the get request. And then, it may cause this error.

而且,dotnet publishing 包含一个隐式 restore 步骤,但是没有适当的系统凭据.因此,即使您在较早的步骤中成功运行了dotnet restore,由于未经过身份验证也可能导致dotnet restore失败,因为在上一个任务完成后将清除凭据.

And also, dotnet publish include an implicit restore step but will not have the system credentials in place. So, even if you have ran dotnet restore successfully in the earlier step, it can also failed with non-authenticated because the credential be cleaned up after the previous task finished.

您可以在参数中添加-no-restore ,以避免隐式还原.有关更多详细信息,请检查此文档:在发布期间运行的隐式还原.

You can add --no-restore to the arguments to avoid implicit restore. For more details, please check this doc: implicit restore that runs during publish.

更多推荐

启用自包含功能会导致dotnet发布因私有NuGet而失败

本文发布于:2023-11-17 08:51:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609519.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:功能   dotnet   NuGet

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!