change solution file to a different folder

How do I change the folder of my existing solution file (sln)?

It's right now inside one of my project's folder; if I cut the solution file and paste it in the root folder,it doesn't load any of my projects.


Solution 1:

Open solution explorer in Visual Studio and select the solution.
Click on File > Save MyProject.sln As ...
and choose the new location.

Solution 2:

The solution file is just a text file. You should be able to move it and then edit it to make sure that any relative paths referenced in the file are correct.

I've also been able to right-click on the solution file in the solution explorer and then use save-as to save it in a different location. That doesn't seem to work everytime for me though.

Solution 3:

Open a blank solution, save it to a location where you would like to move. Then add "Existing Project" and select the Old.sln file to add all the projects under the old solution file.

Solution 4:

I just had to do this with some legacy projects I inherited so thought it might be worth documenting...

After upgrading from VS 2005 solution, I noticed that the solution file was at the same level as the project files. Our standard is to have the solution file one level above.

Undesired location of solution file.

Opening the solution file in 'Notepad' I see the following:

Unchanged Solution file opened in notpad.

Add required relative path to each of the project path and save in correct location:

In my case to bring up one level 'BloombergPriceRequestService\'

SO project line(s) will look like this:

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BloombergPaydownService", "BloombergPaydownService\BloombergPaydownService.csproj", "{17DDDD3E-CD39-48B4-BE3F-71E550FCBBFC}"
EndProject
Global

Don't forget to delete your old solution file! I have moved the solution file up one level

Solution 5:

if I cut the sln file and paste it in the root folder,it doesn't load any of my projects

Do this anyway, and try to open the solution. It will tell you that some projects couldn't be loaded: ignore the warning.

Then, go ahead and delete all the projects from the solution. After this right click the solution and select Add => Existing project and browse to your project file. Repeat for all projects in your solution.