yldbear77
yldbear77

Reputation: 47

I want to change the location of .sln and .vcxproj

below one is the current project structure.

- project
  - bin
  - obj
  - include
  - src
    * a.cpp
  * project.sln
  * project.vcxproj

But I want to create new directory "project". And move .sln and .vcxproj file into "project" directory.

- project
  - bin
  - obj
  - include
  - project
    * project.sln
    * project.vcxproj
  - src
    * a.cpp

Here problem occurred. Because <ItemGroup> components of vcxproj do not update itself, so .sln cannot load all of my files.

In other words, originally a.cpp is written as "src/a.cpp" in .vcxproj file. but after moving .vcxproj, it still remains as "src/a.cpp" not "../src/a.cpp".

I also saw VS 2010, change location of project file. But I could not find the automatic way to update vcxproj when it is moved.

Is there any way to achieve it ? or I have to change all of components of .vcxproj manually?

Upvotes: 1

Views: 1202

Answers (1)

CKE
CKE

Reputation: 1608

Visual Studio just allows to save the solution file .sln at another location. Just select the Solution in the Solution Explorer, go to menu item

File -> Save >MySolution.sln> As...

and save it under another name and/or location.

The project file .vcxproj itself cannot be relocated by a Visual Studio option/menu item. Therefore this has to be done manually and all the pathes to source, resource files etc. shall be updated by the help of a powerful text editor, e.g.

just doing a search and replace.

Checked with Visual Studio version 16, hence VS 2019. Maybe this option will be available in a future version of Visual Studio.

Upvotes: 3

Related Questions