Create Project/solution in an existing directory?

29,673

Solution 1

From Visual Studio, if you have no solution open, you can select

File->New->Project From Existing Code

Select the project type

Put the directory you want the solution and project file to be in as the "Project file location" field.

Finish the wizard and you'll have a project file and solution file in the same directory.

If the "Project from existing code" option is not available

Make a custom keyboard shortcut, toolbar button or menu item by using the customization features of VS.

Tools->Customize

Select the "Keyboard" button to add a keyboard shortcut or select the "Command" tab to add a toolbar button or menu item. The command you are looking for is:

File->New Project From Existing Code

Assign whatever keyboard shortcut or drag an icon to whichever menu/toolbar you want.

Solution 2

To create a solution in an existing directory, I have found the best way is to create it one directory back from where you actually want it, then use the name of the directory where you really want it as the name of the solution.

If that isn't the name you want (i.e. you don't want your solution name to match the name of the directory it is in) then once you have created it, you can rename the solution by right-clicking on it and choosing "Rename". It does not rename the directory it is in nor move it. That is by far the simplest way.

You can obviously use the same trick for a project too, however if you have more than one project in a single directory, ideally the intermediate directory into which they build should differ, otherwise you are going to have issues if you want to rebuild just one of them and it clears out the intermediate target directory.

Solution 3

You can always move things around manually and edit sln file to fix the project references. For example, if you want your solution file to be in the same directory as the project file, you can cut the solution file from wherever it is and paste it into the project file directory. Then you need to edit the solution file to fix the project reference so that the solution can find the project when it is opened.

Share:
29,673
João Paladini
Author by

João Paladini

coder & programmer of many defunct languages...

Updated on November 28, 2020

Comments

  • João Paladini
    João Paladini over 3 years

    How can I create a New project & Solution in the same, existing , directory? No matter what I do, it keeps creating a new (sub)directory for the project and populating that directory instead of the one(s) that already exist. I have the "Create directory for Solution" checkbox cleared so that it will put the solution an dproject in the same folder and not create a solution folder, but it still keeps making the project sub-folder.

    How can I fix this?!?

    This has bugged me for a long time, but I've been able to ignore it or work-around it up until now. But now it is kicking my butt productivity-wise on my customer project and I need to fix it. thanx... RBarryYoung

    (Note: This is VS2005, Team Edition for Software Developers)