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

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.

Related

Project scripts not saved in the Visual Studio list

When I edit the Unity scripts, it opens up visual studio for me, and I manage the code there. Each script opened in visual studio has an x ​​next to its name, so you can remove it from view.
When I don't press the x and leave the script open in visual studio, if I close visual studio and open another script from Unity, the last script selected is shown, and alongside the previous script that I had not deleted with the x (it shows me the previous scripts that I had opened and had not removed).
What I just said happens with 6 of my projects.
The seventh however (not in order), does not behave like this. When I open a script and, without deleting it (from view, not from Unity), I close visual studio, the next time I reopen, the recent scripts are not displayed. I would like them to be displayed.
This is because I have about thirty scripts in the project, and managing the openings from visual studio is much faster than doing it from Unity, as first you have to search for the exact path of the script, and then you must also wait for it to load.
I searched for solutions and tried looking at visual-studio / unity settings, but didn't understand what may be causing this.
I have done the "Reimport All"
I have regenerated the project files
I have reinstalled Unity and Visual Studio Community 2019 from the Unity Hub
There's a .sln file, which references .csproj files, which contain the files within your project. These files are those listed in your solution explorer. These files are generated by Unity and are related to Project files. In Visual Studio in the Solution Explorer, you will see the Solution (.sln file) which contains one or more projects (.csproj), and the files within a project.
Now besides of that, Visual Studio has a lot of settings besides the actual solution and project. These settings are for instance:
How you arrange your view in VisualStudio
Which tabs are opened (Your question refers to the file tabs)
These settings are stored within a .suo file. These .suo files are located within a hidden directory .vs inside your project folder (next to the .sln file). Usually the .suo files and the .vs folder are part of the .gitignore list so they don't get added to the repository, because they are machine specific settings. E.g. you want your VisualStudio to be set up differently than that of another developer in your project.
I think you need to make sure that your .suo files don't get overwritten/changed by any other mechanism. For instance, if the .suo file is added to a git repository, another developer closes all the tabs, and pushes it's .suo file, and you pull that. Then after you reopen Visual Studio all the tabs will be closed. If you open 5 tabs, and push your .suo file, and the other developer pulls it, next time that developer opens VS the 5 tabs will be opened.
You can also try to delete the .vs folder to reset everything. Don't forget to make a backup though.

Visual Studio 2012 automatically opens specific files on start

There are about 6 files that are automatically opened every time I launch Visual Studio 2012, even though they are already closed by me in the previous session. How can I make it so that those files no longer automatically open upon each launch, so I no longer have to manually close them?
Open documents and similar user options are stored in a .suo file in the same directory with your .sln file. If your specific .suo file became corrupted, you can try to manually delete it.
Just make sure close your files and "save your project" again. This should fix it.

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.

Close all files in visual studio on exit

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.

Resources