When developing .NET applications, NuGet packages help us add functionality without writing everything from scratch. However, after installing or updating packages, you may encounter errors like:

NU1605: Detected package downgrade

Package X depends on Package Y (>= 8.0.0)
but Package Y 7.0.0 was resolved

or:

The type or namespace name could not be found

These problems occur when different libraries require different versions of the same dependency.

This guide explains why NuGet conflicts happen and how to fix them in Visual Studio.


What is a NuGet Package Conflict?

NuGet is the package manager for .NET applications.

A NuGet package may depend on other packages.

For example:

Your Application
       |
       |
   Package A
       |
       |
 Microsoft.Extensions.Logging 8.0

Another package may require:

Your Application
       |
       |
   Package B
       |
       |
 Microsoft.Extensions.Logging 7.0

Now NuGet must decide which version should be used.

This creates a dependency conflict.


Common Causes of NuGet Version Conflicts

1. Updating .NET Version

Example:

You upgrade your project:

.NET 7
   โ†“
.NET 9

but some packages still support only older versions.

Example:

Microsoft.AspNetCore.Components.Web 9.0.17

requires:

Microsoft.AspNetCore.Components 9.0.x

but your project contains:

Microsoft.AspNetCore.Components 8.0.x

Result:

Package downgrade detected

2. Installing Incompatible Packages

Example:

You install:

Package A version 5.0

and later install:

Package B version 3.0

Both depend on different versions of the same library.


3. Mixing Framework Versions

Example:

Your project:

Target Framework:
net9.0

but package:

SomeLibrary 6.0

only supports:

net6.0

This can create compatibility issues.


Method 1: Update NuGet Packages from Visual Studio

The easiest solution is updating all related packages.

Open:

Visual Studio
    โ†“
Tools
    โ†“
NuGet Package Manager
    โ†“
Manage NuGet Packages for Solution

Select:

Updates

Then update required packages.

After updating:

Build
    โ†“
Clean Solution

Build
    โ†“
Rebuild Solution

Method 2: Update Package Versions Manually in .csproj

Every NuGet package is stored inside your project file.

Example:

<ItemGroup>

<PackageReference Include="Microsoft.AspNetCore.Components.Web"
 Version="8.0.17" />

</ItemGroup>

Change it to:

<ItemGroup>

<PackageReference Include="Microsoft.AspNetCore.Components.Web"
 Version="9.0.17" />

</ItemGroup>

Save the file.

Then run:

dotnet restore

Visual Studio will download the correct package version.


Method 3: Remove and Reinstall the Problem Package

Sometimes package metadata becomes corrupted.

Steps:

Open:

Manage NuGet Packages

Find the package.

Click:

Uninstall

Then:

Install

again.

Example:

FluentUI.Blazor

Remove:

Version 4.13

Install:

Version 4.14

Method 4: Clear NuGet Cache

If Visual Studio still shows old package versions, clear the cache.

Open Developer Command Prompt:

Run:

dotnet nuget locals all --clear

You should see:

Clearing NuGet HTTP cache
Clearing global packages folder
Clearing temporary cache

Now restore:

dotnet restore

Method 5: Check Dependency Tree

You can find which package causes the conflict.

Run:

dotnet list package --include-transitive

Example output:

YourApp

Microsoft.Extensions.Logging 8.0.0

Dependencies:

Package A
   Microsoft.Extensions.Logging 8.0.0

Package B
   Microsoft.Extensions.Logging 7.0.0

Now you know which package creates the conflict.


Real Example: ASP.NET Core Package Upgrade

A common situation:

Before:

.NET 8 Project

Microsoft.AspNetCore.Components.Web 8.0.17

After:

Upgrade to .NET 9

Microsoft.AspNetCore.Components.Web 9.0.17

But other packages remain:

Microsoft.Extensions.DependencyInjection 8.0.0
Microsoft.Extensions.Logging 8.0.0

Solution:

Update all Microsoft packages to the same major version.

Recommended:

Microsoft.*
        โ†“
same version family

Example:

9.0.x
9.0.x
9.0.x

Avoid:

9.0.x
8.0.x
7.0.x

Preventing NuGet Conflicts

Keep packages updated

Regularly check:

Manage NuGet Packages
        โ†“
Updates

Avoid unnecessary packages

Every extra package increases dependency complexity.

Install only packages your application needs.


Use consistent versions

For Microsoft packages:

Good:

Microsoft.AspNetCore.*
9.0.17

Microsoft.Extensions.*
9.0.17

Avoid mixing:

Microsoft.AspNetCore.*
9.0

Microsoft.Extensions.*
8.0

Conclusion

NuGet package conflicts are common in .NET development, especially when upgrading projects or adding new libraries.

The most effective solutions are:

Understanding NuGet dependency management will save hours of debugging in Visual Studio.

Related articles

๐Ÿค– AlgoLassi Assistant Have a question about this tutorial?

Ask AlgoLassi and get an answer plus the tutorials worth studying next.

Ask a question

๐Ÿ’ฌ Comments

Sign in with Google to publish immediately, or comment anonymously and wait for approval.

Comments will appear here when available.