PDA

View Full Version : How do I use environment variables for file paths



KCL
07-27-2017, 01:01 PM
I have an environment variable PROJ_A setup on my machine, and the continuous integration machine, however the value of the environment variable is different on both machines. The environment variable is the source folder of my files that will be getting installed.

So if, in command prompt, I run
echo %PROJ_A%\test.exe on my machine I'll see
C:\LocalProjects\ProjA\test.exe but if I run the same thing on the CI machine, I'll get
A:\Build\Checkout\ProjA\test.exe.

I'm wanting to set the source folder of a file being installed, to a path that uses an environment variable. Since this is going to run on a CI server, I won't be able to manually go in and change the compiler variables every time I want to build, so there should be a way to do this.

If there already is a way, I appologize in advance--I'm not seeing it.

Thanks,
Kevin

linder
07-28-2017, 01:55 AM
Kevin,

You need the value of the environment variable at compile time, right? The only way to handle it is to write a little "helper application" with SetupBuilder to retrieve the value and then push it back to the SetupBuilder compiler. For example, let your helper.exe retrieve the value of the environment variable and write it to an INI file. At compile time (from your script), execute the helper.exe (using #run... with "Wait" enabled) and after it load your compiler variable with the value (#get ini...). If you need help with this, just let me know.

Does this help?

Friedrich

KCL
07-28-2017, 11:28 AM
Perfect explanation, it works, thanks!

KCL
07-28-2017, 11:29 AM
Although it works, I wouldn't be against being able to use environment variables during compile time. :D

linder
07-29-2017, 02:28 AM
;) Thanks for your suggestion. We'll add a function to support this in the next maintenance build.

Friedrich