If I have 10 files open and I amend my csproj
file (for example: add a space) visual studio complains:
The project "XYZ" has been modified outside the environment. Press Reload to load the updated project from disk. Press Ignore to ignore the external changes. The change will be used the next time you open the project.
Now, I really want to reload cause there are important changes, but I do not want Visual Studio to close all my open files, instead I would like it to refresh the ones that still exist and close the missing ones.
Is there any way to get that kind of functionality?
Found my lost project by going to "C:\Users{Username}\AppData\Local", right clicking on the Local folder, clicking on "Restore previous versions," selecting the appropriate version, and clicking the "Open" button.
You can also specify if you want to restore modified files if Visual Studio shuts down unexpectedly. To access this dialog box, go to Tools > Options > Environment > AutoRecover.
When you create a new project, Visual Studio saves it to its default location, %USERPROFILE%\source\repos. To change this location, go to Tools > Options > Projects and Solutions > Locations. For more information, see Options dialog box: Projects and Solutions > Locations.
A solution is a structure for organizing projects in Visual Studio. The solution maintains the state information for projects in two files: . sln file (text-based, shared) .
Yes, I wrote an extension to fix this problem in VS10 and VS11: http://visualstudiogallery.msdn.microsoft.com/6705affd-ca37-4445-9693-f3d680c92f38
Enjoy.
As this functionality is not built it, I wrote the following macro:
Public Sub ReloadProject() Dim oldFiles As List(Of String) oldFiles = New List(Of String) Dim projName = DTE.ActiveDocument.ProjectItem.ContainingProject.Name For iDoc = DTE.Documents.Count To 1 Step -1 Dim name = (DTE.Documents.Item(iDoc).FullName) oldFiles.Add(name) DTE.Documents.Item(iDoc).Close(vsSaveChanges.vsSaveChangesPrompt) Next Dim projPath As String = DTE.Solution.Properties.Item("Name").Value.ToString() & "\" & projName Dim solutionExplorer As Window = DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer) solutionExplorer.Activate() Dim solutionHierarchy As UIHierarchy = solutionExplorer.Object Dim obj As Object = solutionHierarchy.GetItem(projPath) obj.Select(vsUISelectionType.vsUISelectionTypeSelect) DTE.ExecuteCommand("Project.UnloadProject") DTE.ExecuteCommand("Project.ReloadProject") oldFiles.Reverse() For Each file In oldFiles Dim item = DTE.Solution.FindProjectItem(file) If Not item Is Nothing Then item.Open() item.Document.Activate() End If Next End Sub
When I get the annoying window telling me to reload, I ignore it. And then run this macro after to reload.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With