Visual Studio not showing all source files in Solution Explorer
Asked Answered
P

2

6

*I couldn't find any info online about the exact same issue I'm having

I'm using Visual Studio 2022. Last time, I was working on a C# library, and closed the IDE. I saved all source files, but I didn't save changes to the solution file itself, which is what VS offered me to do when I attempted to close the IDE. I didn't think much of it, since the solution file pretty much holds info about the solution itself, like projects, programming language, etc.

Now, I'm opening a solution with Visual Studio. The tabs for source files are still open, but they're not showing in the Solution Explorer. They were showing in Solution Explorer previously, before I re-opened the solution. Please look at the image below - tabs show fine, Solution Explorer on the other hand, on the right side, is not: IDE Screenshot In the image above, look at the text below Logger.cs tab. You probably can't read this language, but instead of displaying the source file, it just says "Other files".

I tried clicking the Refresh button in the Solution Explorer, but that changes nothing.

Just to clarify, these files are indeed there. From Windows Explorer, this is what the solution directory looks like: Solution Directory Screenshot

One file Visual Studio shows is Class1.cs. Just an empty class file. This is a default source file for Class Libraries (.NET Framework in this project), I've never edited it, probably why it's there.

I just want to know, is this a bug in Visual Studio, or it's entirely normal, that can or cannot be fixed? If it can, how can I fix the issue?

Any help would be appreciated.

Potter answered 18/11, 2023 at 20:12 Comment(3)
So... Visual Studio asked if you wanted to save the project/solution before closing, and you chose not to? That would explain why any changes made to the project/solution were not saved. Right-click on the project and select "show all files". Right click on any file you want to include in the project and select to include it in the project. And save.Whimwham
#49597794Hexangular
@Whimwham I see. Files are showing now, thank you.Potter
E
6

From Visual Studio menu, select Project menu then Show all files menu option which in Solution Explorer will show all files in the current project. Also, you may need to right click on each file that was not showing but is now to right click and select Include in Project context menu item. Once done, select Show All Files to hide folders like obj and bin.

enter image description here

Eclogue answered 18/11, 2023 at 20:38 Comment(3)
OK. "Visual Studio menu". What is the "Visual Studio menu". Are you talking about the tool bar? "Project menu" is that the "Project" item on that toolbar? That DOES open up a sub-menu. Show all files menu"? I'm still making assumptions here but that's not a menu but a menu item. I've clicked that over and over and the folders I manually added to the project in the appropriate location through Windows Explorer are NOT showing in the Solution Explorer.Outguess
See screenshot in my reply.Eclogue
@RichardRobertson Click Project (toolbar one), then Show All Files. In solution explorer, right click on files that weren't showing (they probably have an empty file icon too), select Include in Project. After that, right click Project (toolbar one) again, and Show All Files, to hide files. Then click Save All in toolbar, it's right next to the Save one. This is what they're telling.Potter
J
2

Well, I know the answer is already marked, but there is also a view switch between Folder View and Solution View. Files which exists in repo and are not part of the solution can be viewed by switching to folder view.

enter image description here

Jonathanjonathon answered 30/5 at 13:54 Comment(1)
+1 it's not the most convenient thing in the world, but definitely is an alternative solution. Though, it seems like we can only view/access files that are not part of the project, these source files still do not build with the project (or at least from what I understand).Potter

© 2022 - 2024 — McMap. All rights reserved.