Search code examples
.net-coreazure-devopsnugetazure-pipelinesazure-artifacts

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?


Solution

  • 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.