Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy
Visual Studio

Visual Studio: Fix a NuGet Package Reference That Silently Resolves to a Different Version Than the One Shown in the .csproj

- 15.10.26 - ErcanOPAK

🛠️ The Package Version That Wasn’t the One in the File

A PackageReference listing a specific version tells you the version you asked for – not necessarily the version that’s actually loaded at build or runtime. NuGet’s dependency resolution can bump that to a higher version automatically if a different package you also reference has its own transitive dependency on the same library at a higher minimum version, and unless you specifically open the dependency tree, the version actually running in your app can silently diverge from the one line in the project file that looks like it’s deciding the matter.

🔎 The Problem

<!-- MyApp.csproj -->
<ItemGroup>
  <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
  <PackageReference Include="SomeThirdPartySdk" Version="3.0.0" />
</ItemGroup>

<!-- SomeThirdPartySdk 3.0.0 itself depends on
     Newtonsoft.Json 13.0.1 or higher as one of its OWN
     package references. NuGet's default resolution picks the
     highest version required anywhere in the graph - so the
     version actually loaded is 13.0.1, not the 12.0.3
     explicitly written in MyApp.csproj. -->

dotnet list package --include-transitive

> Newtonsoft.Json      Requested: 12.0.3   Resolved: 13.0.1

✅ Fix: Check the Resolved Version, Not Just the .csproj

  • Run dotnet list package –include-transitive, or check the Dependencies node under the project in Solution Explorer, whenever a package’s behavior doesn’t match the version you believe you’re using – the .csproj’s Version attribute is a request to the resolver, not a guarantee of what it produces.
  • If you genuinely need the exact version you wrote rather than whatever the resolver bumps it to, pin it explicitly with a central package version override or a direct reference with the version you require pinned, and verify the resolved version afterward with the same list-package command rather than trusting the .csproj alone.
  • Before filing a bug against a specific version’s documented behavior, confirm which version is actually resolved and loaded first – a surprising number of version-specific bug reports turn out to be against a transitively-bumped version the reporter never intended to be running.

⚠️ Why This Is Easy to Miss

  • The build succeeds without any warning in the default output – NuGet considers resolving to a higher compatible version a completely normal, successful resolution, not a conflict worth flagging, so there’s no red text or build warning pointing you toward the mismatch.
  • IntelliSense and Go To Definition both quietly follow whatever version actually got resolved, not the one written in the .csproj – so code completion and API availability can look wrong for the version you think you’re on, when they’re actually correctly reflecting a different version you didn’t realize was loaded.

A PackageReference’s version attribute is your opening offer to the dependency resolver, not its final answer – and the final answer is the one your code actually runs with.

— Developer Tip

Related posts:

Visual Studio: Use Code Snippets to Write Code Faster

Visual Studio: Use Code Snippets to Write Code Faster

Visual Studio Debugger Skips Lines — Optimized Build Trap

Visual Studio Debugger Skips Lines — Optimized Build Trap

Visual Studio Builds Are Fast — Debug Is Slow (And Why)

Visual Studio Builds Are Fast — Debug Is Slow (And Why)

Views: 11

Post navigation

Git: Fix git clean -fd Silently Deleting Untracked Files Inside an Uninitialized Submodule
WordPress: Fix a Caching Plugin That Silently Serves the Logged-In Admin Bar’s HTML to Every Anonymous Visitor

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

November 2026
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
30  
« Oct    

Most Viewed Posts

  • How to make theater mode the default for Youtube (1,055)
  • Get the User Name and Domain Name from an Email Address in SQL (980)
  • How to add default value for Entity Framework migrations for DateTime and Bool (977)
  • Get the First and Last Word from a String or Sentence in SQL (858)
  • How to select distinct rows in a datatable in C# (854)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (653)
  • Add Constraint to SQL Table to ensure email contains @ (609)
  • Average of all values in a column that are not zero in SQL (570)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (547)
  • Find numbers with more than two decimal places in SQL (475)

Recent Posts

  • C#: Fix a ConditionalWeakTable Entry Vanishing Too Soon
  • Docker: Fix a Stale COPY Layer After Editing .dockerignore
  • Photoshop: Fix a Pattern Overlay Scaling Wrong on a High-DPI File
  • SQL Server: Fix a Computed Column Index Skipped by Implicit Cast
  • HTML5: Fix a required Input Inside a Hidden Tab Blocking Submit
  • SQL Server: Fix ROW_NUMBER Ties Reordering Between Identical Runs
  • C#: Fix an Enum HasFlag Returning True for the Zero Value
  • WordPress: Fix Featured Images Vanishing After a CDN Migration
  • Photoshop: Fix Content-Aware Fill Smearing a Repeating Pattern
  • Asp.Net Core: Fix Antiforgery Tokens Rejected Behind a Reverse Proxy

Most Viewed Posts

  • How to make theater mode the default for Youtube (1,055)
  • Get the User Name and Domain Name from an Email Address in SQL (980)
  • How to add default value for Entity Framework migrations for DateTime and Bool (977)
  • Get the First and Last Word from a String or Sentence in SQL (858)
  • How to select distinct rows in a datatable in C# (854)

Recent Posts

  • C#: Fix a ConditionalWeakTable Entry Vanishing Too Soon
  • Docker: Fix a Stale COPY Layer After Editing .dockerignore
  • Photoshop: Fix a Pattern Overlay Scaling Wrong on a High-DPI File
  • SQL Server: Fix a Computed Column Index Skipped by Implicit Cast
  • HTML5: Fix a required Input Inside a Hidden Tab Blocking Submit

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com