How can the Solution Explorer in Visual Studio Community 2019 be refreshed? - visual-studio

I have a basic c++ project in Visual Studio Community 2019. It contains three files: main.cpp, log.cpp, and log.h. I created a fourth file called Source.cpp and then deleted this file from the file explorer in Windows 10 to see how Visual Studio would adapt to external changes to files. Source.cpp is still visible in the solution explorer in Visual Studio.
I have tried unloading the project and reloading it but it still appears in the solution explorer. I assume it's best practice to delete files from within Visual Studio's solution explorer but there must be a way to refresh the solution explorer to reflect changes made outside of Visual Studio. Similarly, if I create a new file in the project directory (same directory as the other files in the project), it doesn't appear in the solution explorer. If I unload the project and reload the project, the new files is still not visible.
How can I refresh the solution explorer? My intention here is to better understand how Visual Studio organizes files in the solution explorer and how the organization relates to the actual file/directory structure in Windows.

After playing around with it for some time I realized that you can select the "Show All Files" button on the bar at the top of the Solution Explorer. This has a refresh button that works as expected (updates the Solution Explorer with the current state of the directory folder). It seems that files can be managed from this window and added/removed from the project in Visual Studio's default organization structure.

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 TFS workspace and solution explorer

I have a problem with my team foundation server whenever I change something in the project and then check it in other visual studio can't see the changes when they get latest version of the file or entire project but the change is available in the Source Control Explorer but not in the solution explorer.
I use Team Foundation Server 2013 and Visual Studio 2013 Ultimate.
If the file exists on disk (physically in the folder) but does not show in the solution then it is likely that the file was checked in, but the modification to the solution was not.
On the solution explorer there is a "show all files" button at the top of the page. If you click it you should see the file grayed out. Right click on it and add it to the solution with the "include in project". Now check in the change to the project file.
Everyone will now see it added.
You need to find who is adding files and not checking in the solution. I find a rolled up newspaper is most suitable to rectifying the issue permanently.

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

File Drag & Drop ability in Visual Studio

I was wondering if any one knew of a plug-in or a way to:
I would like to be able to drag files from Solution Explorer to a Windows Explorer window and have the file copied to the location in Explorer.
Currently using VS2005
See VS Explorer - an addin which adds a file and folder browsing window to Visual Studio. It allows you to drag-drop files from Solution Explorer to external folders, vice versa and more.

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