# C++ Visual Studio C++ Question

## Recommended Posts

I have some important questions on the backburner but first I have a question of interest.  When using Visual Studio 2015 with C++  there are predefined environmental variables such as $SolutionDir that are used for the build. I have searched long and hard to no avail. I am trying to modify these in a simple way. I moved my file structure and although it did work relatively (which is great) the build still mentions the old folders' names that were named before the change to the next project. Thank you, Josheir Edit: If it helps they are also called macros. Edited by Josheir #### Share this post ##### Link to post ##### Share on other sites Advertisement 15 hours ago, Josheir said: When using Visual Studio 2015 with C++ there are predefined environmental variables such as$SolutionDir  that are used for the build.  I have searched long and hard to no avail.  I am trying to modify these in a simple way.

I recommend that you avoid hacking VS projects and solutions; they are strongly intended to be managed automatically by Visual Studio.
If you have symptoms of corruption, such as obsolete directory names surviving a solution rename, you should probably reconstruct the solution and projects from scratch.

Can you explain the complications you are adding to normal project building? You shouldn't need to use special variables.

Edited by LorenzoGatti

##### Share on other sites
13 minutes ago, LorenzoGatti said:

I recommend to avoid hacking VS projects and solutions; they are strongly intended to be managed automatically by Visual Studio.
If you have symptoms of corruption, such as obsolete directory names surviving a solution rename, you should probably reconstruct the solution and projects from scratch.

Can you explain the complications you are adding to normal project building? You shouldn't need to use special variables.

Sure, it's something like this:

1>c:\latest\win32project10\win32project10\file.cpp(293)
1>  Win32Project10.vcxproj -> C:\latest hear it\Win32Project10\Debug\Project.exe
1>  Win32Project10.vcxproj -> C:\latest hear it\Win32Project10\Debug\Project.pdb (Full PDB)

Notice there are the unwanted:     Win32Project10

(six to be exact.)

It runs okay, I'm trying to make it pretty!

Thank you,

Josheir

Edited by Josheir

##### Share on other sites

So you basically don't want the project folder inside the solution folder? That's a checkbox when creating a new solution with project.

You can manually copy the project folder to the solution folder level and then remove and re-add the project in Solution explorer.

Note that you can have only one project cleanly in the solution folder then.

##### Share on other sites

Normally Visual Studio will use paths relative to the .sln file, which is represented with the \$SolutionDir variable. That directory is generally the root of the project which can be moved freely to any path and is cloned to other machines through version control.

If you look in the project files typically the files are all relative to that directory. Sub-projects use the solution directory, and that means if you copy a sub-project into a new solution it will automatically use their values in the new solution file. Many tools use this to their advantage to allow per-solution configurations as they are used in many different applications.

Visual Studio's tools take steps to ensure the paths are relative, but it is still possible for you to use hard-coded paths or paths based on other elements, such as paths based on environment variables (e.g. environment variable of TOOL_SDK_PATH).

I'd look through your solution files, project files, property sheets, and similar configuration files to find any paths that are not relative.  Then use the IDE itself to remove those paths and re-add them, verifying that it is using a path relative to the solution directory. If for some reason the tools won't make it relative to the solution's root, I'd edit that by hand being careful to verify the tools still recognize the correct path.

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

(You must login to your GameDev.net account.)

• 15
• 14
• 46
• 22
• 27
• ### Forum Statistics

• Total Topics
634051
• Total Posts
3015254
×