Have you ever modified a Visual Studio project file (e.g., *.csproj) by hand? If you want to do this in Visual Studio, you first have to select ‘Unload Project’, followed by ‘Edit $projectFile’ and finally ‘Reload Project’. The alternative I used is to open the project file in an external editor and, when saved, Visual Studio will prompt to reload the project automatically.
The second method proves Visual Studio will not crash if the project file is modified without it knowing it, or in other words, there is no need to unload the project first.
I’ve had to do this maneuver quite often at work, more often than I would have liked. Last weekend I made an extension for Visual Studio to allow to do exactly what I wanted: skip the unloading and reloading clicks, with the direct option to ‘Edit Project File’.
It’s called EditProj. Feedback is welcome.
Show, don’t tell
After installing EditProj, you’ll find a new item in the context menu (when you right click) of projects in the Solution Explorer (depicted above). You can now edit the project file, save it, and get a prompt to reload the project. See in action how I remove the file “LICENSE.txt” from the project.
After trying out different methods (which resulted in errors that the file cannot be opened), I settled for the hack of copying the contents of the project file into a temporary file, and then update the original project file with the editions made to the temporary one.
If you are interested, check out the source. Contributions / bug reports welcome!