user11597414
user11597414

Reputation:

How to change the location of .sln file of a project?

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

Upvotes: 1

Views: 2993

Answers (2)

Viktor Arsanov
Viktor Arsanov

Reputation: 1583

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

Upvotes: 6

cbp
cbp

Reputation: 25628

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.

Upvotes: 0

Related Questions