Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio incredibly slow when renaming files

I have a medium-sized solution with 99 projects that has recently started behaving weirdly:

1) If I try to rename a file through the solution explorer, VS will seemingly hang, but after a long time (10+ minutes) it will complete the rename operation.

2) I also noticed today that switching to between Debug and Release mode seems to freeze VS as well. So far I haven't let it run long enough to see if that actually completes.

I've tried both Visual Studio 2012 and 2013, and both exhibit the same problem, so that seems to indicate the problem might not be with Visual Studio. I've tried to check in the event log if there's anything there, but nothing jumped out on me. I've also rebooted and run checkdisk, but it didn't find anything wrong.

Running Windows 7 Professional on a fairly high-specced laptop with 8GB RAM and a new SSD

Update: apparently if I have renamed a file once, I can keep renaming it (and other files in the solution) immediately. When I restart VS, it's slow again.

Update2: I left the computer running overnight to try to switch from Debug to Release, and it managed to do so in the 14ish hours between me leaving work and getting back here.

like image 832
Petter Brodin Avatar asked Mar 10 '14 15:03

Petter Brodin


People also ask

How can I rename files faster?

First, open File Explorer and browse to the folder containing the files you wish to rename. Select the first file and then press F2 on your keyboard. This rename shortcut key can be used both to speed up the renaming process or to change the names for a batch of files in one go, depending on the desired results.


2 Answers

Visual Studio can be extremely slow in renaming files if you are using TFS with a "local" workspace as oppose to a "server" workspace, and the total number of files including different versions in the TFS repository exceeds 10,000 items.

Contrary to Microsoft's recommendation, I suggest using a server workspace instead of a local one for much better performance. There are also some other downsides to local workspaces and the only upside is being able to work while your TFS repository is down. That's not much of an upside considering if you can't connect to TFS, you probably can't connect to your LAN and there's darn little work you can do anyway in that situation.

To change to a server workspace for TFS in Visual Studio 2015,

  1. In VS click on File --> Source Control --> Advanced --> Workspaces

  2. In the dialog that opens, select your workspace and click Edit...

  3. Click Advanced... (it does not matter which mapping is selected).

  4. Under Location, select Server and then press OK.

Switching over to server may take ten minutes or more depending on the size of your repository.

Once this is done, renaming files should be nearly instantaneous.

like image 122
Daniel Barbalace Avatar answered Sep 27 '22 23:09

Daniel Barbalace


When testing I'd made an attempt at setting up one of the projects to build on a different server, both in Debug and Release mode. I though I'd cleaned up both, but apparently I'd only done so under the Debug configuration.

Apparently meanwhile that server has decided it hates my machine, which makes my machine freeze while waiting for it.

Closing Visual Studio and manually editing the .csproj file solved the problem.

like image 21
Petter Brodin Avatar answered Sep 27 '22 23:09

Petter Brodin