Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dotnet build in Azure DevOps with private package source cannot restore from private nuget feed

Our project references packages in our private artifact source in Azure DevOps. When building the project in Azure DevOps the dotnet restore completes fine but dotnet build also tries to restore the packages and fails with

Unable to load the service index for source https://myazdevops.pkgs.visualstudio.com/_packaging/OurPackages/nuget/v3/index.json

The work around is adding --no-restore to both the dotnet build and dotnet publish tasks.

Is there some way to have the build and publish start working without there parameters?

like image 744
Mathias Rönnlund Avatar asked Dec 20 '25 19:12

Mathias Rönnlund


2 Answers

I think your workaround is the solution, in the official docs written:

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.

You can't disable this behavior unless you add --no-restore.

See also this question & answer.

like image 105
Shayki Abramczyk Avatar answered Dec 24 '25 12:12

Shayki Abramczyk


I had similar issues with our internal NuGet feed. I resolved it by adding nuget.config file in repository that contains both NuGet.org and our internal NuGet repository.

<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
    <add key="internal" value="URL_TO_INTERNAL_FEED" />
  </packageSources>
</configuration>

Then just specify in your Restore step Path to NuGet.config to this file.

Hope it will help.

like image 26
Nick43 Avatar answered Dec 24 '25 10:12

Nick43



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!