如何在 Azure Pipelines 中添加 NuGet 包源?

How is it possible to add a NuGet Package source inside Azure Pipelines?

我最近在使用 Azure Pipelines,我的构建过程中有一个 NuGet 任务。此进度总是失败,因为 NuGet 源代码中没有名为“BotUtility”的包。这是因为这个包是我自己创建的,并且只存储在 Azure Artifacts 中。

##[error]The nuget command failed with exit code(1) and error(NU1101: Unable to find package BotUtility. No packages exist with this id in source(s): NuGetOrg

Build Pipeline 是否有可能到达 Azure Artifacts 中的这个包?如果可以,我该如何实现?我可以在管道配置中添加包提要源吗?

错误位置有更详细的截图

这是我当前版本的构建管道。

好吧,您可以将 nuget 提要添加到 nuget 任务;

另一种方法是在您的项目中定义一个 nuget.config,并在其中添加您的包:

<?xml version="1.0" encoding="utf-8"?>

<configuration>

  <!-- NuGet packages are now stored globally, see:  -->
  <!-- see:  -->
  <config>
    <add key="globalPackagesFolder" value=".\Packages" />
    <add key="repositoryPath" value=".\Packages" />
  </config>

  <!-- Setup for local packages, not in a nuget source -->
  <packageSources>
    <add key="MY_FEED" value="https://pkgs.dev.azure.com/org/project/_packaging/MY_FEED/nuget/v3/index.json" />
    <!--<add key="LocalPackages" value="./LocalPackages" />-->

  </packageSources>
  <activePackageSource>
    <!-- this tells that all of them are active -->
    <!--<add key="All" value="(Aggregate source)" />-->
  </activePackageSource>

</configuration>