Project scripts not saved in the Visual Studio list - visual-studio

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.

Related

Where does Visual Studio store the watch window data?

I use to have some complex expressions in the watch window and out of a sudden the watch window is completely empty now. Of course I can put the expressions back manually but it would be really interesting to know where Visual Studio stores the watch window data? I doubt that it's stored in some solution related file since after a clean build the watches are still there.
I am using Visual Studio 2013 on Windows 10.
Watch window information is stored in the .suo file for the solution. I couldnt find it in any of the official documentation for, but the breakpoints are there and if you configure the watch window, then close VS, then delete the .suo file and open VS the watch window is empty. After closing VS, restoring the .suo file and opening VS again the watch window configuration is back. This is confirmed for instance by this blog post:
What informations are saved in my .suo file
This file is used by Visual Studio to store user/solution specific
information such as Opened Files, Expanded Nodes in the Solution
Visual Studio .suo fileExplorer, Opened Tool Windows and its
Positions, User Tasks, Breakpoints, Start-up Project, Contents of
Watch window, Whether the project is loaded/unloaded etc. The same
file is used by Visual Studio Addins (VSPackages) to persist
information that are specific to that solution/user.
I don't know where your .suo file went though, did you accidentally delete it?

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.

MS Visual Studio.net - saved source files missing after reboot

The other day I created a MS visual studio 2010 C# project and started coding. I saved the source frequently, but I did not select a destination to save to (just pressed ctrl+s and assumed the source was being saved). However I had to run and threw my laptop in my backpack on sleep. Unfortunately this laptop (acer aspire 5252 fyi) battery drains extremely quickly when on sleep, and eventually my computer shut off. Now I can't find my source files anywhere and I'm going crazy because I know I saved it and it's several days worth of work.
I tried doing a windows search but couldn't find the project files. I also did a little experiment - I created a new project and without saving the entire solution, I pressed ctrl+s on the source files. Save was successful, but I cannot even find the file that's open in the IDE. Even the "open containing folder option" is grayed out (see screen shot).
I really need these source files back. Obviously it's because I didn't save the solution that the source got wiped out, but where do the source files get saved temporarily before the solution is saved?
Thanks.
You are using Visual Studio's support for temporary projects. Nice feature for quicky test projects (and SO answers) but not a great way to ensure that your projects are still there after VS quits. Programming without source control is similarly inadvisable.
Tools + Options, Projects and Solutions, General. Ensure that the "Save new projects when created" option is ticked to minimize the odds that you'll forget to pick a solution folder. Triple-check that creating a new project now gives you a "Location" property in the dialog.
There is a default location for projects to be saved. That is probably where your files went.
In Visual Studio, on the menu, click Tools > Options > Projects and Solutions > General. There is a "Visual Studio projects location".
On my Windows 7 machine, the folder for Visual Studio 2010 is
C:\Users\<username>\Documents\Visual Studio 2010\Projects
Your unnamed project is probably saved with a default name like WebSite1.
If you would like to change that default location, here is some information on how to do that.
Visual Studio temporary projects are normally found in *C:\Users\"User Name"\AppData\Local\Temporary Projects* . It is a temporary folder that is deleted as soon as Visual Studio starts up.
How to save a Temporay Project from above link:
To save a temporary project
In Solution Explorer, choose the solution or project that you want to save.
On the menu bar, choose File, Save or Save As.
The Save Project dialog box opens.
In the , Name box, specify a name for the project.
In the Location box, specify where you want to save the project.
Select the Create directory for Solution check box.
Note: This check box is not available for Visual Basic web projects, Visual C# web projects, or other directory-based projects.
In the New Solution Name box, specify a name that differs from the project name.
Select the Add to Source Control check box if you want to add the solution to a version-control database or repository.
Choose the OK button.

Sync Visual Studio folder/filename structure with file system structure/filenames

I've made a lot of changes (a.k.a refactoring) to my (big) visual studio solution and it appears now that vs solution structure is very different in visual studio from what it is on the disk and TFS.
Is there a way to make file system (and TFS) have the same folder names and file names as in visual studio solution with some tool or script/program/helper add-in?
This is the list of main issues:
- when I rename project visual studio does not rename folder where this project is located
- if I move project, file to different vs folder, it just happens in visual studio, but not on the disk
You can switch between logical or physical folders in the solution by clicking the "Show all files" icon (2nd top left icon in the solution pane). When not activated, you are viewing logical folders in the solution, drag and drop simply re arrange files virtually. When activated, you are viewing physical folders, drag and drop moves files on disk, using the source controller.
No there are no tools that can help you do this automatically.
There is a two step approach to solve it, made easier by installing two add-ons. I prefer to use the Team Foundation Power Tools and the Source Control Explorer Extensions.
From the Source Control Window inside Visual Studio:
Close the open solution in Visual Studio
open the Source Control window in TFS
Move the folders around to match the structure you prefer, with the mentioned add-ons you should be able to drag/drop and rename them more easily
Alternatively, do the changes on file system with the Team Foundation Power Tools explorer extensions installed:
Close the solution in Visual Studio
navigate to your workspace folder using Windows Explorer
use the TFS context menu on the folders to check-out/rename/move the items ans folders
Then re-load the solution in Visual Studio and:
Open the solution and see that a lot of projects don't load.
Highlight a project that couldn't be found
On the project properties window (ctrl-w, p) find the file path item and click the little [...] button to navigate to the new project file location for each project.
Rightclick the projects you've updated this way in the solution explorer and reload them
Rebuild your solution to verify all changes went as expected
Check-in your changes

Hidding source control files within Visual Studio's solution tree

We use Visual Studio 2008 and Surround SCM for source control. SCM drops files into each directory named ".MySCMServerInfo" which are user specific data files that shouldn't be checked into source control. They are similar to the .scc files dropped by Visual Source Safe. We also have several WAPs (Web Application Projects) that we develop. All these .MySCMServerInfo files show up in the solution tree and the Pending Checkins window when they should not. There has to be some way to force VS to ignore files of a given extension because it ignores .scc files. How do I get VS to ignore .MySCMServerInfo files within a WAP?
I have new information about this issue. Setting the hidden bit on .MySCMServerInfo file causes Surround SCM to loose track of the modification state for files. It starts thinking files are out-of-date when they are not, and it always attemps to get new versions.
Instead, set this registry key if you're using Visual Studio 2008:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Packages\
{8FF02D1A-C177-4ac8-A62F-88FC6EA65F57}\IgnorableFiles\.MySCMServerInfo]
Set this registry key if you're using Visual Studio 2005:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\Packages\
{8FF02D1A-C177-4ac8-A62F-88FC6EA65F57}\IgnorableFiles\.MySCMServerInfo]
These will tell Visual Studio to not display .MySCMServerInfo files within the Solution tree and the Pending Checkins view.
Using the file system hidden bit should work.
Late Answer but hopefully useful to others.
I began experiencing this problem when using Visual Studio 2015 with the new ASP.Net 5 Project templates. (I presume this is because the new templates automatically include everything in the folder rather than only showing the things that are listed in the project file).
Showing these files in the Solution explorer change be prevented by right clicking the file and selecting "Hide from Solution Explorer" but this didn't prevent SCM from including them in the Pending Check-ins Window.
The correct way to deal with this problem is:
Select the file(s) in Solution Explorer
Select the File > Source Control > Exclude from Source Control
Reference
NOTE: Right Click in the Solution Explorer DOESN'T have this option.

Resources