简体   繁体   English

VIsual Studio 2022 卡在恢复 Nuget 包上

[英]VIsual Studio 2022 stuck on Restoring Nuget packages

I have same problem like someone have here:我和这里的人有同样的问题:

Visual Studio get stuck on "Restoring packages for solution" Visual Studio 卡在“为解决方案还原包”上

I try the following:我尝试以下方法:

  1. Clear nuget cache from Tools menu.从工具菜单中清除 nuget 缓存。 and temp, %temp% folders from RUN command.和 temp, %temp% 来自 RUN 命令的文件夹。
  2. Clear visual studio cache from here.从这里清除 Visual Studio 缓存。 C:\Users\Dell\AppData\Roaming\Microsoft\VisualStudio\17.0_27e1b93f C:\Users\Dell\AppData\Roaming\Microsoft\VisualStudio\17.0_27e1b93f
  3. Clear.vs hidden folder of solution. Clear.vs 解决方案的隐藏文件夹。
  4. Clean and Rebuild Solution.清洁和重建解决方案。 But stuck into Restoring Nuget packages...)但卡在恢复 Nuget 包中......)
  5. I wait 15 minutes.我等15分钟。 But nothing happened.... (There's bug here?)但是什么也没发生......(这里有错误吗?)
  6. I only use less than 7 nuget packages from nuget.org我只使用来自 nuget.org 的少于 7 个 nuget 包

Here's Visual Studio Log:这是 Visual Studio 日志:

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:更多信息:

  1. I use old *.csproj project template (non-sdk)我使用旧的 *.csproj 项目模板(非 SDK)
  2. I use PackageReference not packages.config我使用 PackageReference 而不是 packages.config
  3. .NET 4.8 .NET 4.8
  4. Windows 7 Windows 7
  5. No proxy used.没有使用代理。 and official nuget.org/api/.... works in browser.和官方 nuget.org/api/.... 在浏览器中工作。

NOTE: this happened when I re-installed operating system.... Sometimes it took time.注意:这发生在我重新安装操作系统时......有时需要一些时间。 Sometimes it freeze and hangs on Restoring Nuget packages... message有时它会冻结并挂起正在Restoring Nuget packages... message

Please how to solve that?请问怎么解决?

According to your description I think the problem is that you used PackageReference and use nuget.exe to restore the packages.根据您的描述,我认为问题在于您使用了 PackageReference 并使用 nuget.exe 来恢复包。

We can see from this link that For projects migrated to PackageReference, use msbuild -t:restore to restore packages instead.这个链接我们可以看到,对于迁移到 PackageReference 的项目,使用 msbuild -t:restore 来恢复包。

You can try msbuild -t:restore instead of nuget restore ***.csproj to restore packages if you are using PackageReference.如果您使用 PackageReference,您可以尝试msbuild -t:restore而不是nuget restore ***.csproj来恢复包。 For more details, please refer to the above link更多详情,请参考以上链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM