2

I had cleared the Nuget cache in my Visual Studio 2022. After that I received errors in ALLyour text my Visual Studio projects. The errors are:

Unable to resolve 'System.IO.Pipelines (>= 8.0.0)' for 'net8.0'. PackageSourceMapping is enabled, the following source(s) were not considered: Microsoft Visual Studio Offline Packages, nuget.org, OfflinePackages.

Unable to resolve 'System.Text.Json (>= 8.0.0)' for 'net8.0'. PackageSourceMapping is enabled, the following source(s) were not considered: Microsoft Visual Studio Offline Packages, nuget.org, OfflinePackages.

and a couple more similar. I tried restoring Nuget Packages but that kept failing. Tried different things from online forums but nothing worked. So I uninstalled Visual Studio from the Visual Studio Installer and downloaded and reinstalled Visual Studio 2022. This did not work either. Seems that even though I uninstalled Visual Studio it apparently kept incorrect settings.

This has effected every project on my computer, so not caused by a setting in one project.

I am at a loss of what to do now. Some forums said to add Package Sources in Visual Studio but nothing tells me what specific package source to add for these files.

This affected all types of projects including but not limited to Blazor apps and Web APIs.

Thanks for any help,

Michael

I expected to be able to successfully build projects.

1
  • Update: I installed Visual Studio on a different computer and move a project there. Everything works fine. That tells me that the problem is with computer wide settings that didn't get deleted when I reinstalled Visual Studio. The projects themselves are just fine. That leaves me with 2 options: 1. If someone knows how to get rid of all of the settings when Visual Studio is uninstalled. 2. Reformat my laptop hard drive and reinstall everything. Pain in the butt, but something that is good to do sometimes anyway. Anyone know how to delete old settings of Visual Studio? Commented May 24, 2024 at 21:54

1 Answer 1

7

I've recently run into this problem and it was caused by a corrupted NuGet.config file.

I fixed it by renaming the %AppData%\NuGet\Nuget.config file (e.g., adding ".old" at the end) and then restoring the NuGet packages by running the command dotnet restore in the project folder.

The command recreated the NuGet.config file and everything worked OK afterwards.

Sign up to request clarification or add additional context in comments.

1 Comment

The difference between the old and the regenerated nuget.config is the old has packageSourceMapping with pattern * pointing to "NuGet official package source" while the regenerated config doesn't have this mapping.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.