I am using Ant under WinXp to build MSVisual c++ projects.
To access "devenv.com", being computer-independent, I would like to use the vsvars32.bat script. Unfortunately, it seems that environment variables are defined only in the "exec" scope.
Example:
<exec executable='"${env.VS90COMNTOOLS}vsvars32.bat/>
<echo message="${DevEnvDir}" />
<echo message="${env.DevEnvDir}" />
<property environment="env2"/>
<echo message="${env2.DevEnvDir}" />
开发者_运维百科
I never get the expected result.
How can I use the "vsvars32.bat" script and access to its env. vars? Is there better way to achieve this?
Instead of calling vsvars32.bat
directly, call it from little helper script that writes the environment settings to a file using set
.
Helper script vsenvwrap.bat
:
@echo off
call "%VS90COMNTOOLS%\vsvars32.bat"
set > vsenv.txt
In your build.xml
call the helper script, then read the settings file vsenv.bat
:
<exec executable="vsenvwrap.bat" />
<property file="vsenv.txt" prefix="env2" />
You can then delete the vsenv.txt file during your build, or in your clean target.
This uses the fact that environment variable listings mostly conform to the format required by java property files.
You can create a small batch file that runs your ant script and in that batch file execute vsvars32.bat before calling ant.
@echo off
setlocal
set TEMP_HOME=%~dp0
call "%VS90COMNTOOLS%\vsvars32.bat"
call "%ANT_HOME%\bin\ant.bat" %*
endlocal
精彩评论