Sergey Aldoukhov
Sergey Aldoukhov

Reputation: 22744

How to use environment variables within Visual Studio 2008 project properties?

For example, is it possible to set the Output path to your app folder within Program Files?

%ProgramFiles%\MyCompany\MyApp\ does not work.

Upvotes: 2

Views: 1736

Answers (3)

JP Alioto
JP Alioto

Reputation: 45127

Do you really want to build to your Program Files directory? You should create a deployment project. Then you can use the [ProgramFiles] as well as many other macros to deploy your application anywhere you want.

Upvotes: 0

Christian Hagelid
Christian Hagelid

Reputation: 8355

quoted by Microsoft here:

Unfortunately this is by design. We do not support using environment variables in the UI however you can edit the file manually in notepad and specify variable names as you were trying $(varname). This workaround will not enable you to make edits to the property in the project properties however.

so changing the OutputPath property in your project file to:

<OutputPath>$(ProgramFiles)\MyCompany\MyApp\</OutputPath>

will work but all it does (as you can see when you open the project again in Visual Studio and look at the project properties) is include the relative path from your solution dir to the output dir.

Upvotes: 1

Jim
Jim

Reputation: 601

in visual basic 2005 the application folder is defined as my.Application.Info.DirectoryPath

that will take you to the application folder of the currently running program

otherwise folders that are kept as variables, ex my docs ; desktop; temp;program files

are in the my.Computer .FileSystem .SpecialDirectories

Upvotes: 0

Related Questions