A project that won't load with NuGet problems is usually failing at restore or at assembly resolution, not at compilation. The fastest fix is to identify which of those two stages is breaking, then clear the corrupted state in the right order: close Visual Studio or your IDE, delete obj and bin, verify the package source and SDK version, run dotnet restore or nuget restore from a command line, and only then reload the project. Reinstalling the NuGet package cache or recreating the .csproj references is a last resort, not a first move, because it destroys evidence about what actually broke.

Read the actual failure before touching anything

The generic "project could not be loaded" panel in Visual Studio hides the real error. Before you delete folders, get the specific message. In Visual Studio, right-click the project in Solution Explorer and choose Reload Project, then open View > Output and switch the dropdown to Package Manager. The restore output names the failing package, the source it tried, and the HTTP status or version conflict behind it.

From a terminal, the equivalent is:

Normal verbosity is enough to see which feed failed and why; diagnostic verbosity floods the log with per-package resolution noise you don't need yet. If the project is an older packages.config-style project, nuget restore MySolution.sln -Verbosity detailed gives comparable information.

The three messages you'll see most often, and what each actually means:

"Unable to load the service index for source " — network, proxy, certificate, or a dead feed URL. The project file is fine. "Unable to resolve 'PackageName' for 'net8.0'" (or whichever target framework) — the package exists in your head but not in any configured source for that framework, or the version constraint is unsatisfiable. "The project file cannot be parsed" or an MSBuild error pointing at a line in the .csproj — this isn't a NuGet failure at all, it's malformed XML or an SDK-style/tools-version mismatch, and no amount of cache clearing will help.

That last distinction matters more than most guides admit. If the error names a line number in the project file, skip to the project-file section below. Everything in between is for genuine restore and resolution failures.

Close every process that holds file locks

NuGet restores write into obj, bin, and the global package folder, and MSBuild nodes routinely keep handles open after a build. Deleting obj while a background build server is alive produces half-deleted folders and errors that look worse than the original problem, sometimes "access denied" or a project that loads but references ghost assemblies.

The reliable sequence:

1: Close Visual Studio, Rider, or VS Code with any C# extension host running. 2: Run dotnet build-server shutdown to stop the persistent MSBuild and Roslyn build servers. 3: Close any terminal sitting inside the project directory. 4: Confirm nothing is still holding the folder — on Windows, handle.exe or Resource Monitor; on macOS and Linux, lsof +D ./obj from the project root.

You'll know this worked when deleting obj and bin succeeds on the first try without a retry. If it doesn't, a process is still holding the files and you'll save time tracking it down now rather than fighting intermittent errors later.

Clear the transient build outputs, not the global cache

These are different things and conflating them is the most common self-inflicted wound in NuGet troubleshooting.

The transient outputs are obj/ and bin/ inside each project folder. They hold the restore graph (project.assets.json), generated props and targets files, and compiled output. They are always safe to delete; the next restore recreates them. project.assets.json in particular is the file MSBuild reads to know where every package landed, and a stale or truncated copy is a frequent cause of a project that loads but shows every using directive as unresolved.

The global package cache lives at ~/.nuget/packages on macOS and Linux (that's %USERPROFILE%.nuget\packages on Windows). Deleting it forces every project on the machine to re-download every package, which on a slow connection can take twenty minutes and doesn't fix most problems anyway. Use it selectively:

Clear one bad package: dotnet nuget locals global-packages --list shows the path, then delete just the offending package's version folder. Clear the HTTP cache, which is a separate and much cheaper target: dotnet nuget locals http-cache --clear. This fixes many "package not found" errors caused by a cached 404 or a stale index response.

A workable rule: clear obj and bin every time, clear the HTTP cache whenever the error mentions a feed or a service index, and clear the global package folder only when a specific package's extracted contents are demonstrably corrupt — for example, a compile error inside a package's own source that appears on a machine where colleagues build fine.

Verify the package source is reachable and configured

If the output says the service index couldn't be loaded, the project is a bystander. Check what sources NuGet is actually using:

You'll get a list with names and URLs, each marked enabled or disabled. Common culprits: a private Azure Artifacts or Artifactory feed that requires credentials you no longer have, a nuget.config in the repo that pins URLs your machine can't reach from home, or a corporate proxy that intercepts TLS and breaks the certificate check.

Test reachability directly without NuGet in the way:

A 200 with a JSON content type means the feed is fine and the problem is local configuration. A timeout or certificate error means it's environmental and you should be talking to your network team or your private feed's owner, not editing project files. If you're behind a proxy, set HTTP_PROXY and HTTPS_PROXY for the terminal session or configure them in nuget.config under .

One more check that catches a surprising number of cases: run dotnet nuget list source from inside the failing project's directory rather than from your home folder. NuGet merges config files from the machine, user, and every directory up the tree, and a nuget.config three levels above the project can silently replace nuget.org with a single private feed.

Pin the SDK and target framework explicitly

A project that builds on a colleague's machine and refuses to restore on yours is often an SDK mismatch rather than a NuGet problem. The symptom is a restore that fails while resolving Microsoft.NETCore.App.Ref or a framework reference you never wrote down.

Check what's installed with dotnet --list-sdks and what the project expects. If there's a global.json at or above the project root, it pins a specific SDK version and the build fails outright when that version is missing. Either install the pinned SDK or update global.json deliberately — don't delete it, since it exists to keep the team on the same toolchain.

For multi-targeted projects (net8.0;net48), confirm that every package you reference actually supports every listed framework. A package that ships only netstandard2.0 and net6.0 assets will resolve fine for net8.0 but fail or warn for net48. The restore output tells you which framework the failure belongs to; read that word carefully, because the fix is either adding a conditional PackageReference or dropping a target.

Repair the project file when the error points at it

If restore or load fails with an MSBuild parse error, the .csproj is malformed. The usual causes are a merge conflict marker left in the file, a hand-edited PackageReference that's missing its closing tag, or a duplicate PackageReference with conflicting versions for the same package.

Open the file in a plain text editor, not the IDE's designer. Look for <<<<<<<, =======, and >>>>>>> first — merges into project files fail constantly and produce exactly this symptom. Next, search for repeated Include="PackageName" entries. MSBuild logs a warning for duplicate package references, and the resolution picks one in an order that's easy to misread, which explains builds that succeed on one branch and fail on another with no visible difference.

For a project that won't even load, the fastest diagnostic is a minimal test:

This bypasses the IDE's project system entirely. If it restores cleanly, the project file is fine and the problem is in how your IDE loaded it — close the solution, delete the .vs folder at the solution root (that's hidden on macOS and Linux, and it's where Visual Studio stores its per-solution caches), and reopen. The .vs folder is pure local state, so deleting it is safe and fixes a surprising share of "loads for everyone else" complaints.

Restore in the right order and read what it says

Once the state is clean and the sources are reachable, restore deliberately rather than letting the IDE trigger it on load, because the terminal tells you more.

The order that avoids most self-inflicted failures:

1: Shut down build servers: dotnet build-server shutdown. 2: Delete obj and bin at the solution level. 3: Clear the HTTP cache: dotnet nuget locals http-cache --clear. 4: Restore with dotnet restore MySolution.sln --force if a normal restore still reports everything as up to date. The --force flag re-evaluates package resolution even when nothing appears changed, which is exactly the situation after a cache clear. 5: Only after a clean restore, open the solution.

Success looks like a restore that exits with code 0 and, in normal verbosity, prints "Restored" lines naming each project. A silent exit with no lines is also success if the assets files were already current. What you're checking next is that the project loads without the yellow warning triangle and that using directives resolve — if restore succeeded but references still show as unresolved, the IDE is holding an old project system state, and reloading the solution (not just the project) is the fix.

Handle the specific cases that resist the general fix

A few failure modes survive the full sequence and need targeted attention.

Packages from a private feed that's gone. The package was deleted upstream or the feed was retired. Restore fails with a 404 on a specific version. The real fix is either restoring the package from a backup feed or removing the dependency, not shuffling cache files. dotnet list package --include-transitive shows exactly which of your direct dependencies pulled it in, which usually narrows the replacement to one or two candidates.

Central package management conflicts. If the repo uses Directory.Packages.props, individual projects must not specify versions. A stray Version= attribute on a PackageReference produces a hard error that reads like a NuGet failure but is a policy violation. The error message names the file; read it before changing anything.

NuGet falls back to an older version. dotnet list package shows resolved versions, and --outdated compares them to the feed. If a project resolves an older version than you expect, look for a Version range rather than an exact version, or a transitive dependency pinning it down. The --include-transitive flag shows the full graph and is the only reliable way to see why a version won.

One project fails, the solution restores. Restore each project individually with dotnet restore on the .csproj path. The solution-level restore may have skipped it, and the project-level output names the failing package directly instead of burying it in solution-wide noise.

Know when to stop and escalate

Most NuGet load failures resolve within the sequence above. The point where continued poking is counterproductive is when restore fails with a credential or authorization error against a private feed you don't administer, or when the same error appears on a freshly cloned copy of the repository on a clean machine.

In the first case, the feed owner needs to grant access or rotate credentials; no local change fixes a 401 or 403 from a server. In the second case, the problem is in the committed project configuration or the package versions themselves, and it affects everyone — the correct move is to file it against the repo with the full restore output rather than modify your local cache, because your workaround won't help your teammates and may mask the real defect.

A useful signal that you've reached that point: you've cleared obj, bin, the HTTP cache, verified the feed responds, and a fresh dotnet restore --force still fails on the same line. Three clean cycles with the same message is the boundary; stop repeating the sequence and capture the evidence instead.