whats is this icon in visual studio source control? [duplicate] - visual-studio

What does this dotted file icon mean? It's a .cs file but it is not behaving right in my project and I've noticed this separate icon in Solution Explorer:
I've checked the MSDN Documentation in three places
Another page at MSDN
Yet another page at MSDN
I've also checked the Visual Studio Documentation itself, which is rather obscurely organized.
I've even checked this website:
Lastly, I found this topic with a similar question but both the question page and the references inside do not have this icon. Thanks for your help.

This means that the file isn't included in the project.
You're only seeing it because you turned on Show All Files.
You should right-click the file and click Include in Project.

You have "Show all files" checked.
The dotted lines indicate files that have not been added to your project.
Right click on the file and click "Include in project" to include the file in your project.

That "dotted" icon mean that that file is not a part of your project or it is hidden and it is not included in your project.
That "dotted" icon is pretty similar to the icon in Solution Explorer called "Show all files". When you click on it you can see all the files and maybe you click on it or you have some issue and your file is not included in the project.
To include it you can right click one of those files go to Include In Project and that will add it to the project, which declares it in the manifest of your project. You can do it like this:

It is not included in your project and/or hidden.

Related

How To View the Project > References Tab and All DLL Paths in non-VB projects?

When you create a VB project in Visual Studio there is a 'References' tab in the Project Properties window. It looks like this:
It's rather a helpful window as it shows the paths to all the referenced DLLs in one place and lets you add and remove references easily.
However this same tab does not appear for projects in other languages making it very difficult to check the path for each referenced DLL.
Can this tab be made viewable or available for other projects? If not, what is the simplest way to view all the referenced DLL paths at once?
Unfortunately the reference tab for the other languages does not exist.
But you can try to edit the xml project, with these steps:
Show the context menu on your project in the window solution explorer
Select: Unload project
Right click and select Edit
Edit the ProjectReference element in xml file
Save and close xml
Reload Project (right click in solution explorer)
I know this is not what you wanted, but it could be a quick alternative to display the path of your references.

Visual Studio: Add existing folder(s) to project

Is there a way to add existing Folders to a Visual Studio Project so that I do not have to do this file by file?
Edit
To make it clear: I want to add references not copies.
If the folder and its contents have already been created and it physically exists under the Project, you can click the Show All Files icon (at the top of the Solution Explorer windows) and then when the folder shows as a dotted icon, right-click it and choose Include In Project and the folder and all its contents are added.
VS 2019
Click on the 'Show All Files' icon at the top of Solution Explorer window.
Then the folders/files of the selected project will be displayed as dotted icons. You can right click any of them and select include in project to include them in the project.
For solution folders, click the 'Show All Files' icon then first exclude the desired folders/files and then include them.
You could open Add Existing Item dialog, select a bunch of files, click on Add's button drop-down menu and choose Add as a link. It will add files as references and won't copy them.
You can drag and drop the entire folder. If all files don't show you can repeat the drag'n'drop procedure for subfolders.
#Mark s answer is good, but if there are hundreds or thousands of files it will be quite cumbersome to add all of them. Plus, it does not provision for new files.
There is another method using the .csproj file. I have used this to add content that is part of a submodule that does not have a .csproj file of its own.
Note that I have used the <Content /> tag, as I did not need any of the linked content during compilation.
<ItemGroup>
<Content Include="..\my\submodule\directory\**" Link="Directory\In\Main\Project\%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
This answer applies to visual-studio-2012 and visual-studio-2013, the most up to date versions at the time the question was asked and this answer was given. More recent versions have improved their handling and have other answers here. For someone using the old versions, this answer still applies.
Answer:
I don't think there is, but if you have all the files in one folder, you can add multiple files in one go. Just mark them all in the add file dialog.
right click the project, and choose "New Solution Explorer view", a window pops up.
and then form the toolbar of the new window ("solution explore window"), you click the "Show All Files" icon.
then include the folders of interest into your project...
If you're working in VS 2019 Community Edition, I find that you can:
Open the parent folder of whatever folder you're trying to add in windows explorer
Right-click and copy that folder
Go to the solution explorer in visual studio
Right-click then paste the folder wherever you want to in the solution tree
In Visual Studio 2019 I could not drag and drop from file explorer or 'Show All Files' and then add them. Instead, while in File Explorer, right click and choose copy, then click on the location within Visual Studio 2019 and right click and choose paste. All of the files in the folder and subfolders will be added.
kburnik's answer worked well for my use-case, but for anyone who needs a scriptable way to bring a lot of folder hierarchy back, you can modify the .*proj file to re-include the folders and files:
<?xml version="1.0" encoding="utf-8"?>
<Project ...>
...
<ItemGroup>
<Compile Include="Path\To\File1.ext" />
<Compile Include="Path\To\File2.ext" />
...
</ItemGroup>
<ItemGroup>
<Folder Include="Only\Empty\Folders\Need\To\Be\Listed\Here" />
...
</ItemGroup>
Just make sure that before you do this, you save the .*proj file if it's still open in Visual Studio.
You can drag and drop the entire folder or missing folders in the project.
If the folder and its contents have already been created and it physically exists under the Project then click on view over the project then you can see all folders and files and you just need to copy files and click on solution in the same folder view and paste all in there
It has been a while since this was originally posted, but here is an alternative answer for a solution folder that is NOT inside of a project. If you only care to be able to look at the physical files from inside visual studio and do not necessarily require to see them in the solution explorer default view, then click on the switch view button and choose the folder view and any physical directory/directories that are under your solution root folder will appear here even if they do not appear in the solution explorer default view.
If however, you want to add a folder tree that isn't too large as a virtual solution directory/directories to match your existing tree structure, do that and and then "add the existing" physical files to the virtual directory/directories. If the physical directory exists in your solution directory it will not copy the files - it will link directly to the physical files but they will appear as part of the solution virtual directories.
Possibly some of you weren't born when this question was first asked!
If you have external directories, you can add them to a solution as a "website". This gives you all the benefits of being able to search through the solution and easily add new files to the website. It doesn't have to contain html, it can be a set of word documents, for example.
So for example, I've got a single solution that contains every sql and oracle query I've ever worked on or harvested from a co-worker. Why? Because it's difficult to keep up with similar sounding field and table names across different databases when you're trying to write a new query.
This also works with TFS.
Check whether that folder is inside project folder or not, if yes:
click Show All files in solution explorer.
now you can see folder name in solution explorer. right click the folder -> Include In Project.
If the folder out of project please copy it into the project directory in the place where we want it.
If your folder exist in another project but you want to add the folder and its content to another project just
-- go to the folder location
-- Copy your desired folder
-- go back to your current project
-- right click on the project and then just paste it.
folder will be added in your current project.
you may need to fix the namspace of the copying file.
You can use the following extension to add a solution folder, which is going to have the same name and the same content as the existing one without it being moved in the file system at all.
Folder To Solution Folder
And here's the link for more information:
https://marketplace.visualstudio.com/items?itemName=CeciliaWiren-CeciliaSHARP.FolderToSolutionFolder
Just drag and drop the folder in solution explorer.

Problem with file name folding in Visual Studio Solution Explorer ("File Nesting")

(Edit for search-ability: called "File Nesting")
I'm not sure if "folding" is the correct term, but the feature I'm referring to is shown in the 1st image below, versus the 2nd one which does not have an expandable tree list node for the code behind file.
Folding:
No folding:
My questions are:
What is the correct name of this feature?
How do I set it?
Why does my Solution Explorer not have this feature enabled when I try to convert my Web Site Project to a Web Application Project?
References:
Upgrading VS 2005 Web Site Projects to be VS 2005 Web Application
Edit
Thanks Sean, but as you can see below, my Nest Related Files button does show up in this project for some reason:
Should have button shown below:
Edit:
I figured out the reason: I accidentally created a C# Web Application Project, and then added VB ASP.NET files to it.
It's called File Nesting.
When a website project is selected in Solution Explorer, the third button in the Solution Explorer toolbar is for "Nest Related Files".
A website project or project file must be selected in Solution Explorer (rather than the root Solution), for the button to appear in the toolbar. The command/tool button is not available when C++/C# projects are selected in Solution Explorer. I don't have a web app project to test but can only conclude that the command is not applicable to web app projects either.
see this related question for a possible registry hack (changing 9.0 to 8.0 in the question's reg script):
Visual Studio 2010 related file nesting
When you are not using a website project, the nesting button in the solution explorer won't appear—but you can still nest files in .NET 5.0 projects.
Here's how you do it:
Open the project's .csproj file. Visual studio can open it in its own viewer, or else you can use your favorite XML or text editor.
Locate or create an appropriate Item Group element. If there's already one that includes some of your files, put it in there for cleanliness and consistency. If there isn't, create a new one.
Create a new Content element for the file you wish to nest. This element's Include attribute should be the name of your desired file.
Add a new DependentUpon child element to your content element. This element's text value should be the name of the file you wish to nest your target file underneath.
Save the project file and Visual Studio will likely prompt you to reload the project. If you did it correctly, your target file should now be nested under your desired file.
There's shockingly few questions and answers that address this situation. The above answer didn't help me, so I figured that I would share what did for posterity.

How is "Add Existing Item..." in Visual Studio meant to work?

I never use "Add existing item..." feature in Visual Studio's Solution Explorer because it is confusing:
it seems to me the way it should work is that if you have a Customer.cs file in Models directory, that you could choose "Add existing item", it would then show you which items exist in that directory an allow you to choose one. Instead, it opens a file dialogue to some seemingly random directory on your hard drive, and I'm not sure if it is going to make a copy of that file, or use it outside the solution, etc.
instead, if I want to "add an existimg item", I go into windows explorer, click file, CTRL-C, click folder in solution explorer, ctrl-v, and it is clear
Do others do it differently? Am I missing something about how "add existing item" in solution explorer is supposed to work?
The folder opens where-ever you last left it...
As for using this feature; by default (Add) it does IMO the least useful thing; copy the file. But if you notice, the add button is actually a drop-down; hit the down arrow and you can add a link to the file - i.e. leave it where it is and reference it by location (Add As Link).
The quick and easy way to do what you are trying to do (add an existing file that already exists within the folder in your project) is:
At the top of the Solution Explorer window is an icon/button for "Show All Files", enable it (if it is already enabled and the file you are looking for is not shown, click "Refresh"). Note that this setting is enabled on a per project basis.
Right click on the file that you want to include and select "Include in Project".
Add Existing file adds the file to the project. Keeping it in the project directory is something different and making it a part of the project is something different. By making it a part of the project, its entry is made in .csproj/.vcproj/etc and then further properties can be set of this file such as specifying a custom build step etc.
And No, it doesn't create a copy of the file in your current project's directory in case of a Visual C++ project. In case of a CSharp Project, it does create a copy.
e.g., I use this when I need to add a bitmap/png file in my project which I have gotten from an external source. I just copy the file to my project directory and then use Add Existing File to add this to the project.
I'm using it. I even didn't know it's possible to ctrl+c ctrl+v in solution explorer.
It's particulary handy, if you want to add something 'as link'.
I do use it but often I just add file as a link. That make it easier to maintain some common classes if you do not want to make full assembly out of them.
As far as my experience goes using this function, it does the same copy and paste that you are describing.

Moving files from one Visual Studio solution to another

What I usually do is create a new file in the solution where I want to use it (same name), copy & paste the contents of a class from the source solution to the target, fix the namespace & imports as needed.
The only other way I know to do it is open the source file in the target solution and then just save a copy into that folder, which can get confusing with two files open with the same name in one solution.
Does anyone have an easier way to do this?
You can just copy and paste the files themselves.
When you have your solution open, look at the top of the solution explorer and you'll see an icon that looks like a page with a page outline behind it and a yellow page (not a very intuitive icon). This is the "show all files" button. Click that and you'll see all the files in your currently selected project (it is project-specific). Highlight any files that you want to include, right-click, and select "Include in Project."
You could just copy the file with Explorer. Or better yet, start refactoring your projects so that you'll create assemblies that are usable by multiple client projects.

Resources