我有一个定制库,它被打包并作为Nuget包发布到此服务器:

https://pkgs.dev.azure.com/my-project-feed/_packaging/my-project-feed/nuget/v3/index.json

据我所知,这是一个公共URL(访问受限[在这种情况下是假的]).

我可以将我的库作为Nuget包添加到我的客户端应用程序中,一切都按预期构建和运行,因此至少在本地一切正常.

然而,在Azure Devop管道上,构建失败,出现以下例外:

##[error]The nuget command failed with exit code(1) and error(NU1101: Unable to find package My.Custom.Package. No packages exist with this id in source(s): {C path}\dotnet\library-packs, NuGetOrg
Errors in {D path}\My.Blazor.Client\My.Blazor.Client.csproj
    NU1101: Unable to find package My.Custom.Package. No packages exist with this id in source(s): {C path}\dotnet\library-packs, NuGetOrg)
##[error]Packages failed to restore

如果我通过DLL将包添加为项目引用,则构建工作正常.

我的第一个怀疑是,这是一个权限问题.我们将此环境设置为首次使用,因此很可能遗漏了一些内容.

What I have tried

定义了两个Project Build Service组,我try 给他们两个Contributor个权限,其中一个只有Collaborator,但这并没有改变任何事情.

My question

  • 这真的是权限问题吗?如果是,哪个服务帐户(或组)需要哪些权限?
  • 如果不是,可能会发生什么?

推荐答案

NuGet.config个文件添加到您的解决方案中,并添加以下行:

 <?xml version="1.0" encoding="utf-8"?>
<configuration>
  <config>
    <add key="repositoryPath" value=".\packages" />
  </config>
  <packageSources>
     <add key="nuget.org" value ="https://api.nuget.org/v3/index.json"/>
      <add key="AzureDevopsSource" value="https://pkgs.dev.azure.com/my-project-feed/_packaging/my-project-feed/nuget/v3/index.json" />
  </packageSources>
</configuration>

然后在您的管道中执行包还原时:

- task: DotNetCoreCLI@2
  displayName: Restore packages
  inputs:
    command: restore
    feedsToUse: config
    projects: '$(path-to-solution)'
    nugetConfigPath: 'NuGet.config'
    verbosityRestore: Normal
    includeNuGetOrg: true

Csharp相关问答推荐

获取Windows和Linux上的下载文件夹

C# Json重新初始化动态类型

在ASP.NET中为数据注释 Select 合适的语言

以自动方式注销Azure身份应用程序

System.Text.Json数据化的C#类映射

将XPS转换为PDF C#

Blazorise折线图仅绘制数据集的一部分

Unix上的.NET(核心):.NET意外地未看到通过P/Invoke系统调用对环境变量进行的进程内修改

如何通过属性初始化器强制初始化继承记录内的属性?

C#中浮点数的System.Text.Json序列化问题

如何防止Visual Studio断点以红色突出显示到整行?

HttpClient SendAsync与多线程环境中的ArchiveZip

源代码生成器项目使用`dotnet build`编译,而不是在Visual Studio中编译?

我可以强制System.Text.Json.JsonSerializer以非递归方式工作吗?

如何使用.NET Aspire从Blazor应用程序与GRPC API通信?

将两个for循环更改为一条LINQ语句

Xamarin Forms应用程序中登录页面的用户名和密码编辑文本之间不需要的空格

用于分钟和秒验证的MudTextfield的正则表达式掩码

与Visual Studio 2022中的.NET框架相比,如何在.NET Core 6中获取错误输出的窗口句柄

根据运行时值获取泛型类型的字典