Search code examples
c#visual-studiopathvisual-studio-2015projects-and-solutions

How to change relative paths to absolute paths in vs solution file without doing it manually


why visual studio uses relative path when you add existing project from outside of solutions directory and how to change this behavior and make it use absolute path?

Original relative project path generated by visual studio by default

at this moment i do open the .sln file and rewrite it manually but it's a problem when there is the large number of projects, i would like to avoid hard coding.

Manually changed to absolute path

i have researched that in properties window there is a project folder field and absolute path is written in it. maybe some suggestions? is it possible to retrieve it using c# app or batch file(i don't know) and overwrite it on relative paths in solution file.

(stackoverflow shows "You need at least 10 reputation to post more than 2 links" so i couldn't post the picture of project folder field in properties window but it's something like in link below its old version as i guess but full path is same as project folder)

Visual Studio Absolute Path to Source File

are there more easy and efficient ways to solve this problem? some Workaround maybe? Any ideas?


Solution

  • I think you are solving the wrong problem here. The reason VS.net uses relative paths is to allow multiple people to share the same project/solution on different machines. VS.net solution structure allows for this if it uses relative paths, but this is very likely to fail if you have more than one developer working on your solution on different machines, using a source code control system.

    Why would you want to embed your own specific personal file system setup into a solution file ?

    My recommendation is to adopt VS.net way of working, i.e. non-specific folder locations and work everything from the solution file location as relative folders.