如何在 Azure DevOps 中更新密码的到期日期

How to update the expiration date on the password in Azure DevOps

同时 运行 Azure 构建管道中的 UnitTest 项目。我收到以下错误:

Restoring NuGet package Microsoft.Portal.TestFramework.UnitTest.6.672.0.5.
  GET https://msazure.pkgs.visualstudio.com/_packaging/ae95f9fe-9452-4aa1-b167-92a7fcfc670f/nuget/v3/flat2/microsoft.portal.testframework.unittest/6.672.0.5/microsoft.portal.testframework.unittest.6.672.0.5.nupkg
  GET https://msazure.pkgs.visualstudio.com/_packaging/d387a8da-063b-4a96-afb8-093924314a98/nuget/v3/flat2/microsoft.portal.testframework.unittest/6.672.0.5/microsoft.portal.testframework.unittest.6.672.0.5.nupkg
  GET https://msazure.pkgs.visualstudio.com/_packaging/ab5b6ade-9b91-4eb5-8dc6-eacc4a5cdda7/nuget/v3/flat2/microsoft.portal.testframework.unittest/6.672.0.5/microsoft.portal.testframework.unittest.6.672.0.5.nupkg
MSBuild auto-detection: using msbuild version '16.8.2.56705' from 'C:\Program Files (x86)\Microsoft Visual Studio19\Enterprise\MSBuild\Current\Bin'.
  GET https://api.nuget.org/v3-flatcontainer/microsoft.portal.testframework.unittest/6.672.0.5/microsoft.portal.testframework.unittest.6.672.0.5.nupkg
  NotFound https://api.nuget.org/v3-flatcontainer/microsoft.portal.testframework.unittest/6.672.0.5/microsoft.portal.testframework.unittest.6.672.0.5.nupkg 57ms
    [CredentialProvider]Using the ADAL UI  flow for uri https://msazure.pkgs.visualstudio.com/_packaging/Toolset/nuget/v3/index.json. User sign-in required in a pop-up authentication window.

说明需要认证。

根据此 post 建议的解决方案是“更新密码 DevOps 的到期日期”。

谁能告诉我如何更新 Azure DevOps 上的到期日期。 我在 post 中没有太多的声誉可以发表评论,所以我不得不创建一个新的 post.

对于本例中的密码,我认为这意味着 PAT 或个人访问令牌。对于生成令牌的任何用户,作为 Azure Devops 中的该用户,单击用户设置 -> 个人访问令牌。然后找到所需的令牌并单击编辑,然后选择一个新的所需到期日期。

更新:确保在定义的 yaml 管道定义中添加 nuget 身份验证任务 here

在您的管道恢复任务中,您select是否选择了以下选项:

通常选择此选项不需要身份验证。

如果您 select 第二个选项,您可以在恢复任务之前添加 NuGet authenticate 任务以配置 NuGet 工具以使用 Azure Artifacts 和其他 NuGet 存储库进行身份验证。

除了使用 NuGet 凭据插件,您还可以使用 dotnet cli 将凭据添加到 nuget 源。

RUN dotnet nuget add source "your-source-url" --name "source-name" --username "useless" --password "$PAT" --store-password-in-clear-text
RUN dotnet restore

这里有一个可以参考

How to update the expiration date on the password in Azure DevOps

根据错误日志,您应该确保可以访问 URL:

https://msazure.pkgs.visualstudio.com/_packaging/Toolset/nuget/v3/index.json

这是一个需要特定权限才能访问的供稿。您可以在您的浏览器中以隐私模式打开此 URL 以检查您是否有权使用您的帐户访问。

如果你可以访问 URL,你可以尝试在你的 nuget.config 中添加以下内容:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="MyAzureFeed" value="https://msazure.pkgs.visualstudio.com/_packaging/Toolset/nuget/v3/index.json" />
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
  </packageSources>

  <packageSourceCredentials>
    <MyAzureFeed>
      <add key="Username" value="YouAccount" />
      <add key="ClearTextPassword" value="xxxx(could be your PAT)" />
    </MyAzureFeed>
  </packageSourceCredentials>

</configuration>

如果您使用私密代理搭建管道,也可以直接在服务器更新密码:

注意:即使我可以在我的浏览器中打开那个 URL,但是在我将那个提要源添加到我的 Visual Studio 作为测试之后,我仍然无法从那个提要中找到这个包,可以只找到包microsoft.portal.testframework(不知道是不是我权限不够):

在获得社区成员的帮助后,我发布了我的最终解决方案,它帮助我 运行 AzureDevOps 构建管道中的单元测试。 我在 运行ning 单元测试之前添加的步骤:

  1. 添加了 NuGet 恢复任务
  2. 添加了 NuGet 身份验证任务

这是构建管道的屏幕截图。