How to add existing project to new solution
Creating a new solution
If the new solution doesn’t yet exist, create it as follows:
- In Visual Studio, File>New>Project
- In the New Project form,
a. In the upper-left pane, choose Installed>Other Project Types>Visual Studio Solutions or search for ‘solution’, lets you select ‘Empty Solution’ b. In Name: enter the new solution’s name sln
c. In Location: enter the parent directory of the new solution’s directory
d. Then OK the form.
Moving an existing project, which is already in one solution, to another solution
I think of a project as being part of a solution (rather than projects being separate from solutions). Therefore, in my solutions, a project’s directory is a subdirectory of that for the solution which contains the project.
- Cut the project’s directory proj and paste it into the new solution’s directory sln
- In Visual Studio, load sln (if not already loaded)
- In the Solution Explorer,
a. Click mouse button 2 on the line Solution ‘sln’
b. In the pop-up menu, select Add>Existing Project
c. Navigate to sln\ proj and select proj.vcxproj
d. Click Open
How come I didn’t see this before? Two things. One was that I expected the function to be on a pop-up made by clicking mouse button 2 on the Solution Explorer entry for the project. The other was I had never before created a solution as such --- only ever created a project, choosing an existing solution or “Create new solution” as the case may be. Not good UI, IMO, to hid the “create solution” functionality under “New Project”. Once the new solution exists, Hans’s method makes the rest of the task easy.
- Tags:: Visual Studio 2022 CSharp
- Status::🌲