/errors/nuget/nu1605-detected-package-downgrade
error NU1605: Warning As Error: Detected package downgrade: X from 8.0.0 to 6.0.0
- tool
- NuGet
- exit code
- 1
- versions
- .NET SDK 6 – 10
- os
- any
error NU1605: Warning As Error: Detected package downgrade: X from 8.0.0 to 6.0.0 means the project references package X directly at version 6.0.0, while another dependency needs at least 8.0.0. NuGet's "direct dependency wins" rule would pick the older version and could break that dependency, so it reports a downgrade. The .NET SDK treats NU1605 as an error by default. Raise the direct reference to the higher version, or remove it.
Reproduce it
Microsoft.Extensions.Logging 8.0.0 depends (through Microsoft.Extensions.DependencyInjection) on Microsoft.Extensions.DependencyInjection.Abstractions >= 8.0.0, but the project pins 6.0.0:
cat > nuget.config <<'EOF'
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
</configuration>
EOF
cat > App.csproj <<'EOF'
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
</ItemGroup>
</Project>
EOF
dotnet restore 2>&1 | grep -oE "error NU1605: .*" | sed 's/ *$//'
exit "${PIPESTATUS[0]}"Output · exit 1
error NU1605: Warning As Error: Detected package downgrade: Microsoft.Extensions.DependencyInjection.Abstractions from 8.0.0 to 6.0.0. Reference the package directly from the project to select a different version. error NU1605: App -> Microsoft.Extensions.Logging 8.0.0 -> Microsoft.Extensions.DependencyInjection 8.0.0 -> Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0) error NU1605: App -> Microsoft.Extensions.DependencyInjection.Abstractions (>= 6.0.0)
The lines after the first one show both paths to the package: through the dependency chain (needs >= 8.0.0) and the direct reference (>= 6.0.0).
Fix
cat > nuget.config <<'EOF'
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
</configuration>
EOF
cat > App.csproj <<'EOF'
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
</ItemGroup>
</Project>
EOF
dotnet restore >/dev/null && echo "restore succeeded"Output
restore succeeded