How to add folders structure in VS2015? - visual-studio

In older versions of VS when you dragged a folder from windows file explorer into your VS solution, it would make a reference to that folder including all the sub folders' structure and files.
In VS2015 when I drag a folder into the solution it simpley makes a reference to all the files in that folder and sub folder but ignore the folder structure.
So it dumps all the files reference under one filter.
Is there a way to get the former behavior in VS2015?

The way that I do this is to add the folders to the project structure (i.e. underneath the .sln file) and then enable "Show All Files" (you may need a "Refresh").
Right click the folders you want to add and click "Include In Project".
(I didn't know about the drag and drop!)

The answer is as follows:
the reason you don't see the "include in project" is : either you created the solution externally to visual studio community or the solution got corrupt
to resolve this:
make a backup the solution (just in case)
in solution explorer - right click the project name , and choose "Rebuil solution"
Press the "show all files" (if not pressed already)
go to the folder you want to include, and now you should see the "include in project" option. Choose it
press again the "show all files" button (on top of the "solution explorer") to once again hide irrelevant files/folders from your solution explorer

Working with VS2015 and SSIS Solution:
Miscellaneous Folder - When I created a Sub-Folder in VS2015 and then Added the files contained therein it added them but not with the Name I Had but the name "Miscellaneous". Not how it worked in previous versions!
I was able to Add a Custom-Named Folder to the Solution but not the Project. When adding existing files to the Project it put them under the aforementioned Miscellaneous Folder.

Related

Visual Studio, Copy files to project directory problem

I have Visual Studio community 2017. coming from eclipse it was just enough to copy file to project directory and hit refresh then files were appearing in project explorer.
In VS, however when I copy some i.e. *.cpp or *.h in windows explorer to project directory, in VS solution explorer I can not see them. switching to folder view I see but can not include them into project.
via drag&drop to solution explorer (project view) I see them but are not part of project and in folder view and actual directory there is nothing.
what is going on with VS? How can I manually copy paste some files into project while they become part of project?
I will note that there's nothing "going on" with Visual Studio in the sense that something is actually wrong with it, it's just that adding files to your project just requires you to actually add them to your solution. Essentially, it allows you to add miscellaneous files to your folders without automatically including them in your build project (for example, if you're working with some test images/files).
To add files/folders to your project you simply right click on your project in the Solution Explorer and then go to Add > Existing Item.... Then, it's just a matter of selecting one (or Ctrl + A/Shift Clicking to select all/multiple files) and then it will add them to your solution.
In the solution explorer pane, click on the show all files button,
it will reveal all files including your pasted file,
Right click on your file and select "include in project".

How do I add an existing directory structure to a visual studio 2013 solution

I have a large directory structure I want to add to a solution. I can't drag the folder into the solution explorer, and there is no button to 'show all files'.
It´s very simple, first copy all directories where you want.
Then open your solution, and select the project that you want add these folders. Go to Project Menu and do click in show all files.
Now you can see your folders in solution explorer.
Next right click in folder and include in project.
Thanks.

How To ReInclude Excluded Folder

So I just performed the coup de gras on my project by accidentally clicking on Exclude From Project instead of Add on my controllers folder.
When trying to add a folder named Controllers I get the error "this folder exists". However, If I try to click on the project -> Add Existing... I cannot select a folder, but only the controllers.
Kind of at a loss here, has anyone had experience with this, or does anyone know how to get the folders back into the solution?
Click on the Show All Files icon in the solution explorer and then simply include the folder:
Visual Studio Express 2012
Select Your Project Folder Click On "Show All Files" icon to show all Excluded Folders And Files
Then Right Click on Excluded Folder or File and Click on "Include In Project"
In my ASP.Net Webforms project after excluding the file I could't find it even under 'Show all files', but they were at project folder so I had to right click on project in Visula Studio then add existing item.
For anyone wanting a different solution, you can also browse to your project in a File Explorer and delete the offending folder (Be sure to copy it somewhere safe first!). Restart Visual Studio and proceed to add the folder as you regularly would.

Visual Studio "resource" project type?

In Eclipse, you can create a "resource" project type which is basically just a folder with some files in it but visible as a separate project in the "solution". How to do that in Visual Studio?
Solution folders seem close but I don't think it's possible to add a solution folder from an existing folder on a disk, is it?
For example, I have a folder named Build with some build files and nested folders in it. I want to be able to edit these files directly from Visual Studio, how do I make them visible in solution folder without manually recreating folder structure using solution folders etc.?
Unfortunately you can't just add/import an existing folder and all its sub-folders in one action, and Visual Studio does not have the concept of a "resource" project type, as you describe it. You can (as you suggest) use Solution folders for this purpose, however, you must first recreate the folder hierarchy in the Solution Explorer, like so:
R-click on the project folder (or any sub-folder) and choose "Add" -> "New Folder" (for C# projects), or "Add" -> "New Filter" (for C++ projects). Then type the name of the folder you want to add. (Build, in your example)
R-click on the newly created folder (still in Solution Explorer) and choose "Add" -> "Existing Item...". Then browse to the corresponding folder on disk, and multi-select all the files/items in that folder which you want to add.
Repeat this process for all sub-folders.
(Note that the folder structure in the Solution Explorer is not required to match the hierarchy on disk. This allows you, for example, to place all your header files and source files in separate folders in the Solution Explorer, but keep them in one folder on disk.)
A workaround is to add an empty website to a solution - though it defines some unnecessary things like web server configuration, it mirrors file system and that is the main thing.
Right-click solution -> Add -> Add New Website... -> Empty Website

adding multiple existing folders and multiple existing files to Visual Studio project in single step

Does anyone have a way to add multiple folders and (existing) files within those folders to a Visual Studio project in a single step (or via macro)? Let's assume all of the folders and files were copied/pasted into the project folder where they need to reside relative to the project folder, but are not actually stored in the .csproj or .vbproj file, which I believe is a requirement to compile those files into the solution/project.
This works great if you have a web application project in your solution, but not so well if you have a .csproj or .vbproj. In that case, you must manually add folders (and nested folders), and add existing files and browse to each one individually, which can take a long time.
In the solution explorer, select the project, click the "Show All Files" button - .
This will show all the files, even those not part of the project. You can now select all of these in the solution explorer (using Ctrl + Click) then right click and go to "Include In Project".
In Visual Studio 2013 (and possibly earlier) you drag the folder from windows explorer and drop it on the project in the solution explorer.
Other answer given in this thread wouldn't work for me as the files I want to add (DTSX files) are in a different folder, and copying/moving them causes other problems. Here is what worked for me:
Using Visual Studio 2015, use Windows Explorer to locate the files you want to add to your project. Copy those files to the clipboard. If DTSX files are what you are dealing with, in the Solution Explorer right-click on SSIS Packages, and then click on Paste.

Resources