Visual Studio hangs constantly during build

前端 未结 13 1636
盖世英雄少女心
盖世英雄少女心 2021-01-31 01:47

Probably between 25 and 50% of the times I build my solution, I see this:

\"The operation you requested is taking longer than expected to complete. This dialog will clos

相关标签:
13条回答
  • 2021-01-31 01:53

    I've found Visual Studio hanging a lot on building larger projects. Turns out it was ReSharper. After I turned it off: Tools -> Options -> ReSharper -> Suspend Now, everything built fine no issues (even on very large solutions, 100+ projects)

    0 讨论(0)
  • 2021-01-31 01:59

    In addition to the felickz's answer which solves (or almost solves) this problem for builds:

    Except the problem during a build I also had problem with the Package Management Console. It took about a minute to wait for it. Using the procmon I found that the NuGet repository folder was parsed each time this window is opened (very smart, Microsoft!). There were about 1000 packages in this folder. After removing everything from the above folder the performance problem diapered.

    Note that my answer relates to the VS 2015 (and may be below). I didn't tested, but suspect in VS 2017 it should be ok.

    0 讨论(0)
  • 2021-01-31 02:00

    Seems like running Visual Studio as Administrator solved the problem for me! (For always running a program as Administrator see How to Run Visual Studio as Administrator by default)

    0 讨论(0)
  • 2021-01-31 02:01

    Had a similar issue, VS would hang for 45 or so seconds then build for 4 seconds and complete. The 45 seconds of hang would not produce any output to GUI and VS would hang.

    Using ProcMon i could see 3 million + file operations on the /packages/ folder via devenv.exe when i would build this project (and would continue for some time after)!! The first steps of the build you can see that it was checking EVERY PACKAGE to see if it needed to do a package restore (it did not)

    Since I tend to blame NuGet for everything, I disabled Nuget Package Restore "allow NuGet to download missing packages" checkbox under Visual Studio -> Options -> Nuget Package Manager -> General. To my delight, the build was very fast. 5 seconds total!

    Turns out that we had enable package restore on build enabled (i think this is on by default now in VS) AND we also had the packages checked into source control. It seems this causes TFS to thrash in some way ... checking for restoring package must trigger TFS to do some source control operation checks.

    FYI this was VS2013 UPDATE 4 - Nuget version: 2.8.50926.663 .. on a sln with NumberOfProjects = 38 , but i could recreate this hang just building a single csproj with 2 dependencies.

    Update:

    Localhost “Rebuild All” on Sln with SccNumberOfProjects = 53 was taking 7:05 with 2 minutes of visual studio frozen / unresponsive

    • down to 4:14 on a 2 core i5 with no freezing
    • down to 2:44 on a 4 core i7

    Also: This was on a machine with various file watcher security tools, likely not adding any speed to this whole process... and possibly to blame.

    0 讨论(0)
  • 2021-01-31 02:04

    I have seen this happen on large projects when MSBuild is running with the diagnostic switch turned on. In Visual Studio, go to Tools / Options / Projects & Solutions / Build And Run, then check the MSBuild project build output verbosity value. If its not set to Minimal, try setting to minimal and see if your builds are able to complete.

    0 讨论(0)
  • 2021-01-31 02:04

    For me the issue was witch an extension that automatically runs T4 templates on build (AutoT4). Disabling it when working with solutions with EF fixed the issue.

    0 讨论(0)
提交回复
热议问题