kudu: Build fails with one custom package source

Symptom

A solution that has a nuget.config with one custom key under <packagesources> will fail to deploy. Upon inspecting the Deployment Details > Activity Logs the user will discover output like the following:

Command: "D:\home\site\deployments\tools\deploy.cmd"
Handling .NET Web Application deployment.
Unable to find version '5.6.4' of package 'Microsoft.Data.Edm'.
Failed exitCode=1, command=nuget restore "D:\home\site\repository\UrlShortening.sln"
Unable to find version '5.6.4' of package 'Microsoft.Data.OData'.
An error has occurred during web site deployment.
Unable to find version '5.6.4' of package 'Microsoft.Data.Services.Client'.
Unable to find version '3.1.0' of package 'Microsoft.WindowsAzure.ConfigurationManager'.
Unable to find version '7.0.1' of package 'Newtonsoft.Json'.
...

The build passes locally in Visual Studio (probably because the NuGet package source is added to the environment by default) as well as on AppVeyor.

Repro: https://github.com/Durwella/UrlShortening/tree/0f85db19f033995f325b14cf9f6fb758961c39f9

Root Cause

The package(s) located at the custom package source will be found. However packages located at the “default” NuGet package source will not be found.

Mitigation

Add the NuGet package source to the nuget.config

<packageSources>
    <add key="NuGet official package source" value="https://nuget.org/api/v2/" />
    <add key="My custom source" value="http://example.packagesources" />
</packageSources>

Suggestion

It’s not obvious that this should be “fixed”. But, given that the build works in other places it is confusing. Either one of the following two options would be helpful in this case:

  1. After a build fails, if it fails due to missing packages and their exists a nuget.config with <packageSources> and the nuget.org value is missing, then print a warning message to the log such as

    Your build failed due to missing packages. If you use standard packages then consider adding the following to the <packageSources> section of your nuget.config: <add key="NuGet official package source" value="https://nuget.org/api/v2/" />

  2. Include a nuget.config in a parent directory that includes the standard NuGet package source. It seems that it will be chained together with the solution-level nuget.config.
    It could be that some users actually want to exclude the nuget.org package source. They could still achieve this using <clear /> as the first line inside of <packageSources>. I’d expect this to be the less-than-20% case.

Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 30 (14 by maintainers)

Most upvoted comments

Oh, @emgarten just told me that you can run dotnet restore --disable-parallel which limits things to a single http connection. So give that a try! You’ll need a custom deployment script to tweak how this is called.

Though it’ll probably run a low slower.

Closing here since there is really nothing to be done in Kudu itself. See also https://github.com/NuGet/Home/issues/4538.

Hey @davidebbo finally got this replicated sorry it took so long. I trimmed out as much as possible to still have a functioning build. Its public at https://github.com/willthiswork89/testnugetfailure