Reputation:
I have same problem like someone have here:
Visual Studio get stuck on "Restoring packages for solution"
I try the following:
Here's Visual Studio Log:
Microsoft Visual Studio Community 2022
Version 17.2.6
VisualStudio.17.Release/17.2.6+32630.192
Microsoft .NET Framework
Version 4.8.03761
Installed Version: Community
.NET Core Debugging with WSL 1.0
.NET Core Debugging with WSL
ASP.NET and Web Tools 2019 17.2.393.26812
ASP.NET and Web Tools 2019
Azure App Service Tools v3.0.0 17.2.393.26812
Azure App Service Tools v3.0.0
Azure Functions and Web Jobs Tools 17.2.393.26812
Azure Functions and Web Jobs Tools
BusinessObjectEditor 1.0
Information about my package
C# Tools 4.2.0-4.22281.5+8d3180e5f00d42f0f0295165f756f368f0cbfa44
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.
CreateLayoutWizard 1.0
Create layout wizard.
Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
NuGet Package Manager 6.2.1
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/
Razor (ASP.NET Core) 17.0.0.2218101+885a343b00bcab620a90c1550c37dafd730ce984
Provides languages services for ASP.NET Core Razor.
SQL Server Data Tools 17.0.62204.01010
Microsoft SQL Server Data Tools
TypeScript Tools 17.0.10418.2001
TypeScript Tools for Microsoft Visual Studio
Visual Basic Tools 4.2.0-4.22281.5+8d3180e5f00d42f0f0295165f756f368f0cbfa44
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Visual F# Tools 17.1.0-beta.22329.1+702b8e77f5fbfe21e6743324c1750503e02f182d
Microsoft Visual F# Tools
Visual Studio IntelliCode 2.2
AI-assisted development for Visual Studio.
More Information:
NOTE: this happened when I re-installed operating system.... Sometimes it took time. Sometimes it freeze and hangs on Restoring Nuget packages... message
Please how to solve that?
Upvotes: 7
Views: 19608
Reputation: 51
We found that if there is delisted nuget package in our csproj then this can cause the same behavior.
For example: https://www.nuget.org/packages/Microsoft.AppCenter.Crashes/4.4.0
This package is delisted and once this package was upgraded to a version which is listed the restore loop went away.
Upvotes: 5
Reputation: 559
I fixed this by updating the Nuget package source in Visual Studio 2022 on a machine that previously had the Visual Studio 2013 nuget package source
"In the Options window, expand the NuGet Package Manager node and select Package Sources."
package source name: nuget.org
package source: https://api.nuget.org/v3/index.json
https://learn.microsoft.com/en-us/nuget/consume-packages/install-use-packages-visual-studio
Upvotes: 1
Reputation: 473
While it is correct to consider the msbuild alternative when using command line, it is still very annoying for anything inside Visual Studio 2022. I am hitting it on many scenarios, like trying to run tests after build was successful.
Fortunately, it is now fixed in the latest Visual Studio 17.5.0 Preview 6.0 https://visualstudio.microsoft.com/vs/preview/
Upvotes: 0
Reputation: 2327
According to your description I think the problem is that you used PackageReference and use nuget.exe to restore the packages.
We can see from this link that For projects migrated to PackageReference, use msbuild -t:restore to restore packages instead.
You can try msbuild -t:restore
instead of nuget restore ***.csproj
to restore packages if you are using PackageReference. For more details, please refer to the above link
Upvotes: 2