Visual Studio project settings

Kyteland

Diamond Member
Dec 30, 2002
5,747
1
81
I can't for the life of me figure this one out, but it has to be simple. I just don't know what I'm looking for. Hopefully someone here can nudge me in the right direction.


What is the appropriate setting in visual studio (specifically VS2005) to change where the generated executable should be run from. The default behavior is that this is wherever the .vcproj file happens to be located. I want to set it to something else.

So for example say I had a simple console application that read in the contents of a file and printed it to the screen. The project might look something like this:

.\project.sln
.\project.vcproj
.\files\input.txt
.\src\main.cpp

and main.cpp looks for the input file in ".\files\input.txt" with this setup. The starting point of the relative path is wherever the .vcproj file is.

Say I wanted to move project.vcproj into an arbitrary directory that wasn't the root project directory but didn't want to change the code in main.cpp. How would I specify that through the project settings? It has to be something like SomeSetting="$(SolutionDir)" or SomeSetting=".\some\path\i\specify" or there's a macro similar to $(SolutionDir) that I can change, I just don't know what SomeSetting is and it's not obvious from trolling through the project properties menu.
 

Lt 486

Banned
Mar 17, 2008
36
0
0
Running VS project working directory is either ./bin/Debug or ./bin/Release by default.

You should get working dir explicitly in your code if your logic requires to locate certain file path relative to executable path.
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
The paths should be relative to the output directories as LT 486 gave them, or ones you have specified in the project properties. As far as I know the executable is launched in the output directory, and that should be its working directory at runtime. Some people don't like this and would want the working directory to be the /bin directory so that they can have one set of resource folders, but personally I think that if the resource structure uses paths relative to the working directory then you should have a separate set of them for release and debug configurations.

So I would look at your VS project settings, because I'm not sure why the project folder should be the runtime working directory, and second I would take a look at your choices on the relative paths used, and see if you can't arrange it so they are always in the same place relative to the working directory.
 

Kyteland

Diamond Member
Dec 30, 2002
5,747
1
81
Yes that was exactly it. It's hard to figure out what to do when you don't know what you're looking for. ;)

In every console application I've run it defaults to the directory where the project file is located. When you execute it through the IDE it does whatever magic it needs to change the working directory to point to the output directory.