Close all files in visual studio on exit - visual-studio

Is there any way to close all files in Visual Studio on exit? Alternatively if that isn't possible is it possible to delete the user project file visual studio creates on exit?

Windows->Close All Documents
File->Exit
or manually delete the .sou file after the project is close
You can probably write a VB script macro that does either of these.

Related

Visual Studio: Auto reload solution

When working with Unity in Visual Studio, my solution gets often changed from an external source. When Visual Studio realizes that my solution has been changed it asks if I want to reload my solution or not. In my case, I always want to reload it.
Is there a way to skip the dialog box that presents various options and simply always have it reload the solution?
EDIT: I'm using Visual Studio 2015/2017
This is what you are looking for :
Tools > Options > Environment > Documents > Detect when a file is changed outside the environment > Reload Modified files.....
For Visual Studio 2017 :
A thought occurs. Have your external script that modifies the solution, use the Visual Studio automation model to close the solution, then make your updates, and then re-open the solution?
You could write a Visual Studio extension that adds a menu command to the IDE to invoke your script, unless it's automatic, and then simply choose the command from the menus to invoke your script, wait for it to finish, reloading your solution in the process, and then you're there.

How can I open a certain file automatically when opening a project in Visual Studio 2015

in some of my Visual Studio projects I have a file named "info.txt"
When I open a project VS remembers the files from the last session and restores them.
Is it possible to change this so that nothing is restored from previous sessions when I open a project and instead only a single file like "info.txt" is opend automatically ?
You can do it with my Visual Commander extension.
To Prevent Visual Studio from remembering last opened files you subscribe to DTE.Events.SolutionEvents.BeforeClosing and call Window.CloseAllDocuments.
To Open a file from the solution directory on opening a solution you subscribe to DTE.Events.SolutionEvents.Opened and call DTE.ItemOperations.OpenFile.

vsix opens visual studio

I seem to have got my system into a bit of a pickle with respect to Visual Studio extensions.
Normally I would use Nuget.
When an extension is not on Nuget, I'd download the vsix file and double-click on it to start the installation process. But now, when I double-click on the vsix file, it opens it in the Visual Studio text editor, treating it as a file to be edited, rather than executing it as a file to be executed.
Anyone know how I can restore the correct, intended behaviour?
Thanks
First way: if you open regedit and see keys under HKEY_CURRENT_USER\Software\Classes.vsix, just delete that entire key. That should allow the global registrations in HKLM to take effect again.
Otherwise, right click on the file, Open With, and choose "C:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\VSLauncher.exe".

Visual studio 2010 stuck

I've opened a XAML file in VS2010 that crashes Visual Studio.
The problem is that when I close VS and reload it again the XAML file automatically opens and crashes my VS again.
I don't know how to solve this loop.
Is there a way to open the solution with all files closed?
You could delete your solution's '*.suo' file. This file contain the information about the open editors. If you delete it visual Studio will not open any editor when loading the solution.
However you might lose some other customizations as well but in general there is nothing really important in this file and Visual studio will automatically create a new .suo file
I will try even a more violent method.
Move it into trash, and then bring up Visual Studio 2010.
Open another file in Visual Studio so your XAML file opening record will be washed out by the new one.
Close Visual Studio, and then restore your XAML file.
I'm pretty sure that Microsoft's file system won't track where your XAML file go and then tell Visual Studio to open it in the new location, but putting it in trash temporally is a great option.
Try temporarily move the xaml file to another location. (or rename) so VS cant find it, then you should be able to open.

Is there anyway to tell Visual Studio not to open all the documents when I load solution?

When you open a solution in Visual Studio 2008 (or ealier versions for that matter), it opens all the documents that you did not close before you closed Visual Studio. Is there anyway to turn this functionality off, or a plugin that fixes this behavior? It takes forever to load a solution with 50 files open?
Have you tried deleting the .suo file?
It's a hidden file that lives beside your solution (sln) file. suo is "solution user options", and contains your last configuration, such as what tabs you left open the last time you worked on the project, so they open again when you
reload the project in Visual Studio.
If you delete it, a new 'blank' suo file will be recreated silently.
You can automate the process of closing all the files prior to closing a solution by adding a handler for the BeforeClosing event of EnvDTE.SolutionEvents -- this will get invoked when VS is exiting.
In VS2005, adding the following to the EnvironmentEvents macro module will close all open documents:
Private Sub SolutionEvents_BeforeClosing() Handles SolutionEvents.BeforeClosing
DTE.ExecuteCommand("Window.CloseAllDocuments")
End Sub
Visual Studio 2008 appears to support the same events so I'm sure this would work there too.
I'm sure you could also delete the .suo file for your project in the handler if you wanted, but you'd probably want the AfterClosing event.
From Visual Studio 2017 Update 8 there is an option in projects and solutions which you can use to enable this:
ALT-W-L
That's the key combination to close all open tabs, which can be pressed before closing a project, unless you prefer clicking Window | Close All Documents before closing the project.
--Gus
I dont think there is an option for this (or I couldnt find one) but you could probably write a macro to do this for you on project open.
This link has some code to close open files which you could adapt:
http://blogs.msdn.com/djpark/
I couldnt find the answer to this particular question but a good link for ide tips and tricks is:
http://blogs.msdn.com/saraford/default.aspx
Alternative answer:
Before you close your solution, press and hold Ctrl+F4, until all windows have been closed.
VS attempts to save the last known view. Other than the scripts mentioned above you can manually close all documents before exiting VS

Resources