Visual Studio "resource" project type? - visual-studio-2010

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

Related

Adding Existing folder(s) to a C++ Project in Visual Studio without creating a copy

I have a Visual Studio Solution containing multiple projects. (One Main Project and rest are used for testing the Main project)
Here, i have a shared folder within the solution which is used by all the projects within the solution.
I need to include the entire shared folder in my Main project instead of adding existed items.
I am using Visual Studio Professional 2015 and i could not find "Add Existing folder" option in Visual Studio.
Adding Existing items to a project will eliminate the folder structure in solution explorer which makes the usage more complex when included file count is huge.
I need to maintain a folder structure within the project.
Moving the shared folder within the project directory and using "Show All Files" option will avoid the issue(tried based on the answers in some links) but it is not accurate in my case as the folder is being used by different projects.
Do i have any way to add existing folder (Outside the Project within the solution) to a project and maintain a folder structure so that the solution explorer looks more readable?
I just found the solution to this issue.
We are suppose to create a Filter (Virtual Solution Folder) within the Project. Option for creating Filter is available on following below steps,
Select Visual Studio Project.
In Solution Explorer, Disable "Show All Files" option.
Note: When "Show All Files" option is enabled, your project will have an option to create a Folder instead of Filter.
Create a Filter/Virtual Solution folder. (Name could be same as the existing folder name outside the VS project in order to maintain readability)
Now, add required existing files to the Virtual Folder Solution from any location.
(Inside/Outside project location)
By following the above steps, one can add set of existing files to a virtual folder structure in Visual Studio Solution. This is equivalent to adding an Existing folder to a Project Solution without copying it.

How can I organize my source files in a VS .NET project?

To create a new class in Visual Studio, I hit Ctrl+Shift+A, then select "Class". The class creation dialog does not give me any option to put the file anywhere. Visual Studio creates the file in the solution root dir.
So now my solution root dir has 20+ files and a mix of .cs, .sln, .csproj etc files.
I want to be able to view my project in a tree structure, where I organize the class files into a folder hierarchy. How can I do this in Visual Studio?
You can create new folders in your solution tree (in mouse right-click menu) and place your new files there (you probably can even drag files from another location). 20+ files is not much of course :)

How can I use files in one project to create a library in another project in Visual Studio?

I have a standalone project that contains some code I'd like to re-used. I created a library project in order to contain that code. There does not appear to be a way to move files from the one project to the other. (cut/paste in solution explorer did not work)
I then manually copied the files in Windows explorer (outside of VS) into the library's main "folder" but they didn't show up in solution explorer either.
Anyone know of a way to do this without having to manually create each file in the library and then copying/pasting the code into the files?
You need to copy the files and paste them into your solution/project folder(s). Once the files physically exist within your solution/project folder structure (Windows FileSystem / Explorer), then you right-click on your project within Visual Studio, select Add then Existing Item. Browse to the location of that file and open it. It will now exist within your project as a code file.
If you have two projects within the same solution, you can simply drag the file from one project to the other within Visual Studio Solution Explorer. That will create a copy of the class in the new project. You can then remove the old one and clean up any code references in the first project.

How to add folders structure in VS2015?

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.

VS 2010: Add as Link a complete directory of XML to a solution Folder? (no project exists at this level)

I need to add (as link) a complete directory structure that lives under my solution folder but not under any project folder.
Is this possible, i can't seem to find it.
I suppose 1 option is to add a new project type and then add these files under that project..
But it seems not a good way, what type of project type do i add, a c# class project? The files i wish to include are standard XML files and nothing to do with C#
Any ideas or i get around this?
This is possible in Visual Studio 2010 Professional and above. You can add a solution folder and then include files within that folder. Just right click the solution in the Solution Explorer and choose Add|New Solution Folder. Once the folder is added, right-click it and select Add|Existing Item... to add each of the files that you want to access from that folder.
Solution folders are symbolic (i.e. they don't have to map to a single physical location) so you can store shortcuts to files from many different file system locations under the same solution folder.

Resources