1

I have 2 different projects in 1 solution but the .sln file is in one of these projects. I want the .sln file to be above them. You will understand better when you see images.

The ss of my solution explorer:

a busy cat

Here you can see there are 2 projects in 1 solution. Also the name of solution and one of my projects is the same here.

Here is the place .sln file is located:

a busy cat

I want this .sln file to be located in here above them:

a busy cat

How do I do that? Thank you, have a nice day

  • 4
    Move the sln file to where you want it to be. Open the file in a text editor and change the paths to the projects inside it. – mjwills Aug 12 '19 at 11:39
  • 4
    If you don't feel comfortable with editing the solution file you could simply create a new blank solution at the desired location and add the projects to it. If everything is to your liking you can delete the old solution .sln file – Filburt Aug 12 '19 at 11:41
  • In VS2019(I guess in other version it also exists) there is a menu item File -> Save *.sln as, you can try it - place the new solution one level up. – Viktor Arsanov Aug 12 '19 at 11:42
  • With only 2 projects you could create a new .SLN and add both to it. – H H Aug 12 '19 at 11:52
  • Does this answer your question? [change solution file to a different folder](https://stackoverflow.com/questions/3377917/change-solution-file-to-a-different-folder) – T.Todua Jul 21 '20 at 20:33

2 Answers2

5

If you have existing solution with projects I think the easiest way would be to select File -> Save *.sln as and select the location you need.

enter image description here

Visual studio will automatically update paths to projects.

I had something like this in the old solution

Project("{FAE04... "ConsoleApp7\ConsoleApp7.csproj", "{E0C7925E..."

The new one has

Project("{FAE04... "ConsoleApp7\ConsoleApp7\ConsoleApp7.csproj", "{E0C7925E..."

Checked for VS 2017 and 2019.

P.S. The solution should be selected in the Solution Explorer, else the "Save *sln as" item doesn't appear(it will suggest to save something else).

enter image description here

Viktor Arsanov
  • 1,285
  • 1
  • 9
  • 17
0

The sln file is relatively easy to edit in any text editor.

Close Visual Studio, move the solution to where you want it, then open the solution file in a text editor. Change the references to the proj files so that the relative path is included.

Here is an example from one of mine:

enter image description here

In this case, each of the proj files is in a subfolder and the sln file is in the root directory.

Community
  • 1
  • 1
cbp
  • 25,252
  • 29
  • 125
  • 205