从副本发布 nuget 包

publish a nuget package from a copy

看来我的队友们已经关闭了他们的 nuget 服务器去度假了。 我需要一个临时解决方法,以便我的 Azure Dev Ops 构建在恢复 nuget 包时不会失败。

我在

有一个包的本地副本

C:\Users\kirst.nuget\packages\mypackagetemp

我想发布到临时供稿。

我阅读了说明 on publishing a package from the command line 但对第 6 步感到困惑 我当然不需要设置项目和恢复包,因为我已经有了 .nupkg

我试过命令

c:\nuget\nuget.exe push -Source "TempFeed" -ApiKey az mypackagetemp.nupkg

但出现错误

unable to load the service index for source https://pkgs.dev.azure.com/mycompany/myproject/_packageing/TempFeed/nuget/v3/index.json

当我重复命令时,我收到了凭据请求 当我输入我连接到 Azure Dev Ops 的凭据时,它们不起作用。

[更新]

我被提示输入凭据..阅读它...太混乱了。

[更新]

我将nuget.exe从5.1.0.6013升级到最新版本5.4.0.6315 这次我得到一个UI登录和消息

Your package was pushed

然而,当 devops 管道构建运行时,我收到一条消息

unable to load the service index for source
https://pkgs.dev.azure.com/mycompany/myproject/_packageing/TempFeed/nuget/v3/index.json

我想我需要以某种方式创建一个 index.json 文件。

我的项目正在使用 mynuget.config,它在 packagesources

中包含以下内容
 <add key="TempPackage" value="https://pkgs.dev.azure.com/mycompany/_packaging/myfeed/nuget" />

[更新]

我把mynuget.config改成了

  <add key="TempPackage" value="https://pkgs.dev.azure.com/mycompany/_packaging/myfeed/nuget/v3/index.json" />

现在开发操作构建显示消息

Failed to retrieve information about 'Serilog.Enrichers.Thread' from remote source 'https://pkgs.dev.azure.com/mycompany/_packaging/myfeed/nuget/FindPackagesById()?id="Serilog.Enrichers.Thread'', response status code does not indicate success: 404 (Not Found).)

我的解决方案确实使用了 Serilog。我不认为第 3 方包使用它。

[更新]

下次构建时,我在寻找 WindowsAzure.Storage

时遇到了不同的错误

每次构建管道时,我似乎都会收到导致错误的不同文件。

我的项目工件有 2 个提要。所需的文件在未选择的提要中。

[更新]

我尝试编辑 mynuget.config 以使用 index.json 但是我遇到构建错误

The nuget command failed with exit code(1) and error(Unable to load the service index for source https://pkgs.dev.azure.com/mycompany/_packaging/myfeed/nuget/v3/index.json. Response status code does not indicate success: 404 (Not Found - The feed with ID 'MyFeed' doesn't exist

[更新]

因为新提要是基于项目的,所以我将 mynuget.config 编辑为

  <add key="TempPackage" value="https://pkgs.dev.azure.com/mycompany/myproject/_packaging/myfeed/nuget/v3/index.json" />

现在可以了!

在 Azure Devops 门户网站中,对于您当前的项目,转到 Artifacts 选项卡并确保您的包 mypackagetemp.nupkg 在那里可用。

对我来说,我将自定义 LibraryCore.nupkg 推送到那里。现在让我们点击Connect to feed设置,选择nuget.exe,你可以看到:

将完全相同的内容复制到您自己的 mynuget.config 文件中。然后您的构建管道可以访问您发布的 mypackagetemp.nupkg

Failed to retrieve information about 'Serilog.Enrichers.Thread' from remote source 'https://pkgs.dev.azure.com/mycompany/_packaging/myfeed/nuget/FindPackagesById()?id="Serilog.Enrichers.Thread'', response status code does not indicate success: 404 (Not Found).)

The next time I built I got a different error looking for WindowsAzure.Storage

这些包(Serilog.Enrichers.ThreadWindowsAzure.Storage 和...)都在 nuget.org 中可用,因此您还应确保已将 nuget.org 添加为配置文件中的包源:

另外:

根据您的描述,除了使用您的 mynuget.config,您只需要使用您的自定义 devops 提要和来自 nuget.org 的其他包,您可以配置您的 nuget restore 任务,例如这个:

直接选择 devops 提要(第二条红线)Feeds I select here 而不是我的 Nuget.config 中的提要。并选中 Use packages from nuget.org 复选框。然后您可以在构建期间访问自定义提要和 nuget.org 中的包。