Asp.net core Docker容器中私有Github包的NU1101导致dotnet还原失败,但可以在我的本地计算机上运行

Asp.net core Docker容器中私有Github包的NU1101导致dotnet还原失败,但可以在我的本地计算机上运行,asp.net-core,.net-core,nuget,nuget-package-restore,dotnet-cli,Asp.net Core,.net Core,Nuget,Nuget Package Restore,Dotnet Cli,我已经向Github包发布了一个NuGet包(BuildingBlocks)。我使用一个nuget.config文件来指定我的项目的nuget源,以及我的包的凭据(专用于替换为占位符的凭据): 我的BuildingBlocks包没有诸如注释和本地化之类的名称空间,因此我不知道为什么dotnet CLI会将它们写入输出。有人知道如何解决这个问题,或者为什么会发生吗?我的假设是,您的BuildingBlocks包是在GitHub包提要中定义的。如果是这样的话,那么它将与位于的现有包冲突。不幸的是,N

我已经向Github包发布了一个NuGet包(BuildingBlocks)。我使用一个nuget.config文件来指定我的项目的nuget源,以及我的包的凭据(专用于替换为占位符的凭据):


我的BuildingBlocks包没有诸如注释和本地化之类的名称空间,因此我不知道为什么dotnet CLI会将它们写入输出。有人知道如何解决这个问题,或者为什么会发生吗?

我的假设是,您的BuildingBlocks包是在GitHub包提要中定义的。如果是这样的话,那么它将与位于的现有包冲突。不幸的是,NuGet.config中指定了解析包和多个提要时的NuGet。实际错误的原因是nuget.org中的BuildingBlocks包依赖于错误中列出的那些尚未发布到nuget.org的其他包

解决此问题的最简单方法是将包重命名为与nuget.org中存在的包名不冲突

另一个选项是创建具有上游源的单个NuGet提要,允许您确定地控制包的提要源。我不知道这是否可以在GitHub中完成,但我知道可以在Azure DevOps中完成:

上游来源的好处

上游资源使您能够在单个提要中管理产品的所有依赖项。我们建议将给定产品的所有包发布到该产品的提要,并通过上游源从同一提要中的远程提要管理其依赖关系。此设置有几个好处:

  • 简单性:您的NuGet.config、.npmrc或settings.xml只包含一个提要(您的提要)
  • 确定性:提要按顺序解析包请求,因此在相同的提交或更改集中重建相同的代码库时使用相同的包集
  • 出处:您的提要知道它通过上游源保存的包的出处,因此您可以验证您使用的是原始包,而不是发布到提要的自定义或恶意副本
  • 放心:通过上游来源使用的包保证在首次使用时保存在提要中。如果上游源被禁用/删除,或者远程源关闭或删除您所依赖的包,您可以继续开发和构建

谢谢你的回复。我将重命名该包,因为我目前没有在我的项目中使用Azure,但我将为链接添加书签以供将来参考。再次感谢您抽出时间来帮忙。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <!--To inherit the global NuGet package sources remove the <clear/> line below -->
    <clear />
    <add key="nuget" value="https://api.nuget.org/v3/index.json" />
    <add key="github" value="https://nuget.pkg.github.com/<username>/index.json" />
  </packageSources>
  <packageSourceCredentials>
    <github>
      <add key="Username" value="<username>" />
      <add key="ClearTextPassword" value="<password>" />
    </github>
  </packageSourceCredentials>
</configuration>
  Determining projects to restore...
/app/src/DocumentService.Application/DocumentService.Application.csproj : error NU1101: Unable to find package BuildingBlocks.Annotations. No packages exist with this id in source(s): github, nuget
/app/src/DocumentService.Application/DocumentService.Application.csproj : error NU1101: Unable to find package BuildingBlocks.Localization. No packages exist with this id in source(s): github, nuget
/app/src/DocumentService.Application/DocumentService.Application.csproj : error NU1101: Unable to find package BuildingBlocks.IoC. No packages exist with this id in source(s): github, nuget
/app/src/DocumentService.Application/DocumentService.Application.csproj : error NU1101: Unable to find package BuildingBlocks.Nullability. No packages exist with this id in source(s): github, nuget
/app/src/DocumentService.Application/DocumentService.Application.csproj : error NU1101: Unable to find package BuildingBlocks.Domain. No packages exist with this id in source(s): github, nuget
/app/src/DocumentService.Application/DocumentService.Application.csproj : error NU1101: Unable to find package BuildingBlocks.Commands. No packages exist with this id in source(s): github, nuget
/app/src/DocumentService.Application/DocumentService.Application.csproj : error NU1101: Unable to find package BuildingBlocks.Option. No packages exist with this id in source(s): github, nuget
/app/src/DocumentService.Application/DocumentService.Application.csproj : error NU1101: Unable to find package BuildingBlocks.Queries. No packages exist with this id in source(s): github, nuget