🛠️ Visual Studio: Fix IntelliSense Still Showing a Downgraded NuGet API
Downgrading a NuGet package (reverting from v8 back to v6, say, to dodge a breaking change) often leaves IntelliSense still completing members from the newer API long after the restore finishes, because the Roslyn workspace that drives completion caches its view of each referenced assembly’s metadata keyed to the project’s obj folder and the solution’s .vs cache, not to the live contents of the NuGet global-packages folder. If the design-time build that seeded that cache ran before the downgrade actually took effect, Visual Studio keeps suggesting methods and overloads from the package version it last resolved, even though project.assets.json now correctly lists the older one.
🔎 The Problem
Downgrade: ExampleSdk 8.2.0 -> 6.1.0 in the .csproj dotnet restore completes without errors, project.assets.json now shows 6.1.0 Editor still shows completion for: client.SubmitBatchAsync(request, CancellationToken) <- added in 7.0, removed again in 6.1 Build from the command line: error CS1061 'ExampleClient' does not contain a definition for 'SubmitBatchAsync' (IntelliSense never flagged this before the build)
âś… Fix: Force the Workspace to Re-Resolve the Downgraded Metadata
- Close the solution, delete every project’s
binandobjfolder plus the solution’s.vsdirectory, then reopen so the Roslyn workspace performs a fresh design-time build against the package versionproject.assets.jsonnow actually lists. - Run NuGet Package Manager > Clear All NuGet Cache(s) before restoring again whenever you’ve just downgraded, since a stale copy in the global-packages or http-cache folder can get picked up even after the project file says otherwise.
- Treat a downgrade as a reason to do a full command-line
dotnet buildimmediately, rather than trusting a clean-looking Error List, since IntelliSense’s cached metadata and the compiler’s actual resolved references can disagree for an uncomfortably long time after the version number changes.
🚨 Why This Is Dangerous
- Shipping code that compiles cleanly in the editor because IntelliSense is still quietly offering a method signature from the version you just downgraded away from, only to have the real compiler — or worse, a teammate’s from-scratch clone — reject it with a missing-member error that never showed up locally.
A stale cache doesn’t know you changed your mind about a dependency — only a from-scratch restore does.
