Every time while relocate : Add Files to Project  
Author Message
prayami





PostPosted: Visual C++ General, Every time while relocate : Add Files to Project Top

Hi,

In our project there are many files I have to add from different directories. And that is working fine. But if I

relocate that project folder then path of all the added files is changed. And I have to delete those files and add

the same files again every time. Is there any way to give relative path to this files so if I change the location

then I need not add all the files again.

Thanks



Visual C++14  
 
 
Mike Danes





PostPosted: Visual C++ General, Every time while relocate : Add Files to Project Top

The files are always added using a relative path as long as this is possible (that is when the file you add is on the same drive as the project file).

Note that even if you use relative paths you need to move both the project and the files and keep the same "relativeness" between them.


 
 
C.Nic





PostPosted: Visual C++ General, Every time while relocate : Add Files to Project Top

- add an environment variable called let's say SRC_ROOT. Make it point to whatever location where your sources are.

- unload your project from Visual Studio

- edit the vcproj file using Wordpad

- replace any path pointing to your files with something like $(SRC_ROOT)\myfile.cpp

- save and load the project again

Whenever you relocate your project is enough to give a proper value to the SRC_ROOT environment variable and everything will work fine.

For example, let's say your sources are C:\MyProject\MyClass.cpp and C:\MyProject\MyClass.h

The .vcproj should be edited to look like (just a snapshot):

<File

RelativePath="$(SRC_ROOT)\MyClass.cpp"

>

some more stuff here

</File>

<File

RelativePath="$(SRC_ROOT)\MyClass.h"

>

some more stuff here

</File>

And the SRC_ROOT environment variable should be set to C:\MyProject. If you move everything to let's say c:\new_project_location, you have to change only SRC_ROOT to be "c:\new_project_location"