使用私有包源在 Azure DevOps 中构建的 Dotnet 无法从私有 nuget 源恢复
Dotnet build in Azure DevOps with private package suorce cannot restore from private nuget feed
我们的项目引用了 Azure DevOps 私有项目源中的包。在 Azure DevOps 中构建项目时,dotnet restore
完成正常,但 dotnet build
也尝试恢复包并失败
Unable to load the service index for source https://myazdevops.pkgs.visualstudio.com/_packaging/OurPackages/nuget/v3/index.json
解决方法是将 --no-restore
添加到 dotnet build
和 dotnet publish
任务。
有没有什么方法可以让构建和发布在没有参数的情况下开始工作?
我在使用内部 NuGet 提要时遇到了类似的问题。
我通过在包含 NuGet.org 和我们的内部 NuGet 存储库的存储库中添加 nuget.config 文件来解决它。
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="internal" value="URL_TO_INTERNAL_FEED" />
</packageSources>
</configuration>
然后只需在还原步骤中指定 NuGet.config 到此文件的路径。
希望对您有所帮助。
我认为您的解决方法是解决方案,在 official docs 中写道:
Starting with .NET Core 2.0 SDK, dotnet restore runs implicitly when
you run dotnet build. If you want to disable implicit restore when
running the build command, you can pass the --no-restore option.
除非添加 --no-restore
.
,否则无法禁用此行为
另请参阅 问答。
我们已经在Github中打开了源代码,您可以参考dotnet build command. This is a compile command, so we did not make script in the task to set the authinfo additionally. Also, as you know, the dotnet restore
runs implicitly while the dotnet build
running only after .net core 2.0. In fact, this dotnet restore
which runs implicitly is not a necessary part if you have been run dotnet restore
before the dotnet build
. That's why we offered the workaround的代码-添加--no-restore
-避免这种隐式命令。
这是一种非常方便的方法,可以让你的编译过程非常简洁。但是如果你仍然不想要这个参数,你需要做另一个配置工作来授权凭据。
配置 Azure Artifacts Credential Provider, then pass in the credentials with the VSS_NUGET_EXTERNAL_FEED_ENDPOINTS
environment variable。 VSS_NUGET_EXTERNAL_FEED_ENDPOINTS
包含您需要使用 JSON 格式进行身份验证的任何提要的端点凭据。
我们的项目引用了 Azure DevOps 私有项目源中的包。在 Azure DevOps 中构建项目时,dotnet restore
完成正常,但 dotnet build
也尝试恢复包并失败
Unable to load the service index for source https://myazdevops.pkgs.visualstudio.com/_packaging/OurPackages/nuget/v3/index.json
解决方法是将 --no-restore
添加到 dotnet build
和 dotnet publish
任务。
有没有什么方法可以让构建和发布在没有参数的情况下开始工作?
我在使用内部 NuGet 提要时遇到了类似的问题。 我通过在包含 NuGet.org 和我们的内部 NuGet 存储库的存储库中添加 nuget.config 文件来解决它。
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="internal" value="URL_TO_INTERNAL_FEED" />
</packageSources>
</configuration>
然后只需在还原步骤中指定 NuGet.config 到此文件的路径。
希望对您有所帮助。
我认为您的解决方法是解决方案,在 official docs 中写道:
Starting with .NET Core 2.0 SDK, dotnet restore runs implicitly when you run dotnet build. If you want to disable implicit restore when running the build command, you can pass the --no-restore option.
除非添加 --no-restore
.
另请参阅
我们已经在Github中打开了源代码,您可以参考dotnet build command. This is a compile command, so we did not make script in the task to set the authinfo additionally. Also, as you know, the dotnet restore
runs implicitly while the dotnet build
running only after .net core 2.0. In fact, this dotnet restore
which runs implicitly is not a necessary part if you have been run dotnet restore
before the dotnet build
. That's why we offered the workaround的代码-添加--no-restore
-避免这种隐式命令。
这是一种非常方便的方法,可以让你的编译过程非常简洁。但是如果你仍然不想要这个参数,你需要做另一个配置工作来授权凭据。
配置 Azure Artifacts Credential Provider, then pass in the credentials with the VSS_NUGET_EXTERNAL_FEED_ENDPOINTS
environment variable。 VSS_NUGET_EXTERNAL_FEED_ENDPOINTS
包含您需要使用 JSON 格式进行身份验证的任何提要的端点凭据。