31

On the current project I am working on, there is, at the moment, a large churn of code, which means updating from source control can mean at times many csproj file changes. As we all know, VS2010 doesn't have a "Reload all" button, but you must reload each project and confirm each reload.

Is there a method where either the project is auto-reloaded or the IDE can detect this and ask for a solution reload?

Elliott Beach
  • 10,459
  • 9
  • 28
  • 41
Ray Booysen
  • 28,894
  • 13
  • 84
  • 111

4 Answers4

29

Finally found a solution:

http://lostechies.com/jimmybogard/2011/01/27/reloading-all-projects-with-vscommands/

Quoting from the site:

Quite often I’ll find myself working in situations where multiple projects have changed, and Visual Studio asks to reload them, one at a time. This happens when I’m working a lot with source control, and doing things like switching branches, performing merges, or just integrating upstream changes. I have to click “Reload” a million times for each project that changed on disk, and it’s quite annoying. On top of that, VS forgets which files I have open, so every file that I was working on gets closed.

I may be the last VS user to find out about this, but a free lite version of the VSCommands plugin is available on the Visual Studio Gallery that does just what I need – reload all changed projects at once, preserving which files I had open:

CharlesB
  • 86,532
  • 28
  • 194
  • 218
Ray Booysen
  • 28,894
  • 13
  • 84
  • 111
  • 2
    When the link dies, the solution is lost forever. Could you please improve your answer by describing the fix? Thanks! – sam hocevar Jun 29 '11 at 08:07
  • @RayBooysen: You might want to update the link and remove the Google Analytics parameters (they will distort the site's statistics)- http://lostechies.com/jimmybogard/2011/01/27/reloading-all-projects-with-vscommands/ will do. – Oliver Jan 28 '13 at 10:34
  • Just wanted to mention that if you need VSCommand's pro feature to keep the previously opened files open after a project reload, check out this small VS Extension by Scott Hanselman: [Workspace Reloader](http://www.hanselman.com/blog/IntroducingWorkspaceReloaderAVisualStudioAddInToSaveYourOpenFilesAcrossProjectReloads.aspx). – Oliver Jan 28 '13 at 10:36
  • 2012 version of VSCommands http://visualstudiogallery.msdn.microsoft.com/a83505c6-77b3-44a6-b53b-73d77cba84c8 – Tim Abell Sep 26 '14 at 09:47
4

It's a pain, but the best option I've found is to Close the solution before Getting the latest source code.

If there are more than two changed projects, it is faster to manually unload&reload the entire solution than it is to Get and wait for it to unload&reload the affected projects only - reloading projects is achingly slow (even disregarding having to click the OK button for every project that changed).

(In my mind the real question is: Why does it ask that question at all??? If you Get the latest source code, there is absolutely no sane reason why you would want to only use part of it. It's like a petrol station attendant saying "You've bought some fuel. Would you like me to now actually put it in your car, or shall I just pour it out on the ground?")

Jason Williams
  • 56,972
  • 11
  • 108
  • 137
  • The problem is that with most tools (in our case VisualSVN or AnkhSVN), you don't know what has changed until you click update. And then you play the "Reload project" game with Visual Studio. – Ray Booysen Jan 26 '11 at 09:45
  • @Ray Booysen: I just realised an improved approach: Just GLV as normal. If it asks if you want to reload a changed project, click "Ignore" - you can whizz through all the changed projects quickly by ignoring them, and then Close/Reopen the solution afterwards to get everything in sync. This avoids the need to close/open the solution around every GLV - you only do it if a project has actually changed. – Jason Williams Feb 03 '11 at 11:05
  • It's still a dance I'd prefer not to do with VS. ;) – Ray Booysen Feb 04 '11 at 08:51
1

Well, that doesn't work if your references paths changed in the csproj file and your using something like the sysinternals junction tool to change a symlink. E.g. tool switches D:\Projects symlink from D:\Baselines\1.0\Prjects to D:\Baselines\2.0\Projects , and because someone changed the folder structure between 1.0 and 2.0, your .csproj file suddenly points the dll path from ....\References\some.dll to ....\References\3rd-Party\some.dll . I know that is a special case, but happens (e.g. in my company).

There is an alternative solution though, one which I highly recommend as it has other benefits, too: the not-so-well-known VS 2010 Extension Solution Load Manager. It defers loading of Projects to the background, or until manually loaded, improving solution load time a lot for large solution files. It has this "reload solution" button in it's menu (unfortunatlely there seems to be no shortcut) which then reloads all solutions from scratch, skipping/backgroundloading the solutions you set. A Microsoft guy commented on his blog that they wanted to include something similar into VS 2010, but the feature didn't quite make it.

Sure, it may take longer then "just" one click and updating 100 documents, but it solved my problem of (relative) reference path changes, and gives a nice speed boost every time I open an at least medium sized solution.

Edit as of Oct 2013 VS2012 includes this functionality by default. At least the async loading stuff. The "don't load at all" functionality is unfortunately only possible by using manual "unload project" in VS2012. But as pr-project memory consumption did go down with VS2012, it's not that big of a deal anymore.

hko
  • 923
  • 9
  • 17
-3

If you have checked the option "detect when file is changed outside the environment" in the "Documents" section of options, projects and files are reloaded when changed. It works for me when switching branches in git.

VS option screenshot

CharlesB
  • 86,532
  • 28
  • 194
  • 218
  • Up to VS 2010 (at least) no such feature as auto-reloading modified project files exist - you'll always have to play the "Reload Project" game with Visual Studio if a project files changes outside of it. – Oliver Jan 28 '13 at 10:39