Nuget restore in Docker fails on latest SDK (6.0) but works on specific version (6.0.201)

Viewed 88

I have an existing project that is using a specific SDK tag (6.0.3) in the Dockerfile. It works fine, but when I tried updating it to use the floating 6.0 tag, or the latest 6.0.400 tag, it fails:

/app/src/redacted/redacted.csproj : error NU1803: You are running the 'restore' operation with an 'HTTP' source, 'http://redacted/repository/nuget/'. Non-HTTPS access will be removed in a future version. Consider migrating to an 'HTTPS' source. [/app/redacted.sln]
  Failed to restore /app/src/redacted.csproj (in 77 ms).
The command '/bin/sh -c dotnet restore' returned a non-zero code: 1
ERROR: Service 'dependencies-build' failed to build : Build failed

Why are the HTTP warnings causing the build to fail on the 6.0 tag? I thought Nuget HTTP support was not going to be removed until a later version.

1 Answers

If you have TreatWarningsAsErrors turned on then Nuget will promote these HTTP warnings to errors and exit with an error code.

The solution is to either:

  1. Update the project to use HTTPS for connecting to the repository
  2. Ignore the specific error by adding it to the NoWarn list.
  3. Turn off TreatWarningsAsErrors

In that order of preference.

Bear in mind that TreatWarningsAsErrors (and NoWarn) may be in the .csproj file or may be in a common Directory.Build.props file.

Related