How do I add a folder, not a "filter", in Visual Studio 2013? - visual-studio

I have a Visual Studio 2013 project within a folder called 'Source', let's say. I'd like to have some additional folders within that folder and I'm trying to find a way to do that. If I, in visual studio, create a new 'filter' (which looks like a folder) and create a file within it. It might appear to be within a new folder (as displayed by Visual Studio), but it actually is in the default Source folder.
I try a second approach and create the folder with the help of the operating system. I even create a file within it manually. Then I go to visual studio and add an existing item, selecting the file WITHIN the folder. Visual studio then adds the file, which is good, but its displayed as being in the default directory.
I suppose there is a very manual way. And thats mirroring everything. Creating a folder using the operating system. Creating a filter within visual studio, etc. And mirroring everything manually.
Is there a different way or do I create a better IDE in 2 days?

Simple Drag and Drop should work.
Keep your directory with source inside your project directory.
Drag and Drop directory structure from windows explorer to visual studio existing project.
Click "Show All Files" option in the top of Solution Explorer toolbox
After doing this you need to add this directories in your project.
Select that directory, right click and select "Include in project"
You are good to go!
Details here

Related

Creating an installer for Visual Studio 2010 solutions (one or more projects)

I ran into some troubles when creating an installer for my Visual Studio 2010 solution (which has multiple projects) so I thought I'd make a quick guide to how I got it working...
Here is how I did it:
Create a new Visual Studio Installer project which is located under
Installed Templates/Other Project Types/Setup and Deployment/Visual Studio Installer.
Make sure you add it to you current solution, you can do this by right clicking on the solution name in the solution explorer and clicking Add>New Project
From there select Setup Wizard, give it a name and click OK
A wizard will open, click Next
then select Create a setup for a Windows application
then click Next again. Select all of the groups you want to include, namely: Content Files, Source Files, Primary Output
Then click Finish
In the solution explorer you will see a bunch of buttons find the one that's tool tip says File System Editor and click it. You will see three folders in the file system editor, the only one we really care about is the Application Folder. That folder is where your projects build output should be.
To add files to it if they are not already there right click > Add > File...
Note: You cannot add entire folders (which sucks) and the folder structure in the Application Folder should be identical to that in your projects build.
You should create each folder and then add the files to it.
If you have multiple projects you should set the build directory to the same folder under the release build settings. To do this, open your solution, and for each project, right click/Properties go to the Compile tab, set it's configuration to Releaseand its Build output path to some folder (same for each project) (If you have an XNA project make sure its Content Build/Configuration is also set to Release).
Now select Release from the drop down menu on the tool bar (it most likely says Debug now)
Right click on your solution on the solution explorer and click Build Solution
Now all of your solutions built files will appear in the folder you chose in the compile tab. All of these files are what needs to be added to the Setup Projects Application Folder (in the same structure)
Customise the installer: click on the project name in the solution explorer and look through it's properties, change what you want (i.e Author, Manufacturer, Title - these make a difference to the installers output directory and text)
Build the installer project (same way as mentioned above) and you are done.
Feel free to comment with questions

Create Visual Studio Solution from Batch File

Visual Studio seems to consist of a single solution file (*.sln) along with one or more project files (a C# project would have the *.csproj extension).
I have been playing around with a console application that parses existing directory entries to create solution files with the associated project files.
It works, but every time I run into a new project here at work I find myself spending a week or more debugging my console project so that it can churn out a solution for that particular work project.
Is there something out there already that can create a VS solution out of an existing file structure?
As you can tell from my screen capture below, these projects are nested very deep, so it would take a very long time to do this with the apps folder below with the "by mouse" technique in the Visual Studio IDE.
I created the custom console application that is posted in this post:
https://stackoverflow.com/a/22153536/153923
I invite others to contribute how they approached this solution, though.
So, I found out today that this feature already exists in Visual Studio.
Link 1: How to: Create a Project from Existing Code Files
Link 2: How to: Create a Project from Existing Code Files
Basically, though, it says this (just in case the MSDN links get changed or deleted):
You can create a Visual Studio project from an existing app—for example, an app that you obtained from an online source. Project and solution files are created on your computer and the other relevant files are added. A project can be created from Visual C++, Visual Basic, or Visual C# code files.
Security note Security Note
We recommend that you determine the trustworthiness of existing code files before you import them into Visual Studio, because Visual Studio will execute some of the code in a fully trusted process when you open the newly created project.
To create a project from existing code files
On the menu bar, choose File, New, Project From Existing Code.
The Create New Project from Existing Code Files wizard opens.
Use the wizard to specify the details of the existing code files that will be added to the project and the application that will be created when you build the project.
Another good answer was given by cbp in Visual Studio: Create a web application from existing code:
--
OK I figured it out. It's weird, but the following steps will work:
Open fresh copy of Visual Studio
File->New Project, select Web Application
Use the following settings:
Name: Website (this is the name of the existing folder with the website files in it)
Location: C:\Temp\ (anywhere will do for now)
Solution Name: TheProject (name of the existing project's root folder)
Check "Create directory for solution"
Delete the auto-created Default, Global and Web.config files
Save All and close Visual Studio
In Windows Explorer, copy the new folder on top of the existing folder so that the files are merged.
Double click on the sln file to open Visual Studio again.
Select "Show all files" (at the top of Solution Explorer)
Right click on any files or folders you want to add and select Include in Project.
Great idea!

Create a physical copy of a source file in Visual Studio

In Visual Studio, if I try to copy a file from one project to another (by using Copy and Paste or by dragging the file to the new project while holding the Ctrl key) it creates a reference to the source file in the original location. Is there a way to create a physical copy of the source file and place that in the target project source direction without having to resort to using Windows Explorer to copy the file manually?
It's not pretty, but when I want to do what you're suggesting, I double-click on the file in Visual Studio, which opens it. Then I do a File->Save As, choose the right directory and save it. All from within Visual Studio. This is usually followed by adding the new file to the other project.
Was just doing this and realized I should mention a side-effect. Depending on your source control (in my case, TFS 2010), doing this from within Visual Studio may modify the location of the file in the project. For me, this means making sure that neither the file nor its project have any pending changes, doing the save as, then doing an undo of the change this causes in TFS 2010 (project change, file add and delete).
From http://msdn.microsoft.com/en-us/library/0fb6xxhb.aspx:
If you are working with solution items, Visual C++ projects, or other similar projects, you are always working with links in Solution Explorer. If you are working with Visual Basic projects, Visual C# projects, and other projects, you might be working with links or files.
Essentially, the answer to my question is 'No'. In most cases, I must use Windows Explorer.

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.

How to add an existing folder to a Visual Studio project?

I have a web application project made in Visual Studio 2008.
Well, I added a jquery folder and added it to source control and other such things. I forgot to add it to the visual studio project though. How do I add the existing folder now? I've tried just creating a new folder and naming it jquery but it gave me a cryptic error "the directory is already on the disk ... if you want to see this directory then check the Show All Files option in the project file" Yet I looked and saw no such option.
Is the only way around this to rename jquery to jquery2 and then create a new folder via visual studio named jquery and copy all my files into it?
With your project open in Visual Studio, click on your project. Then go to the "Project" menu and select "Show All Files". You should now see any directories or file that are in the directory of the project but not included in the project.
Then, right-click on the folder you want to add, and select "Include in Project" from the context menu.

Resources