If it were me, I'd add something like...

< IsTfsBuildAgent Condition=" '$( IsTfsBuildAgent)' == ''">no</ IsTfsBuildAgent 
>
...
    <DefineConstants>
      $(DefineConstants);
      IsTfsBuildAgent =$(IsTfsBuildAgent);
    </DefineConstants>

To your WixProj. Then you should be able to do:

<?if $(var.IsTfsBuildAgent) = "yes" ?>
    <?define SourcePath = ".\..\..\binaries" /> <?else ?>
    <?define SourcePath = "..\bin\$(var.Configuration)" /> <?endif ?>


Better yet, you could use SourcePath as a MSBuild property and pass it in as a 
constant.


-----Original Message-----
From: RHaggard [mailto:hagg...@msn.com] 
Sent: Monday, October 07, 2013 11:45 AM
To: wix-users@lists.sourceforge.net
Subject: [WiX-users] How to detect an environmental variable's value?

I'm trying to set up a wxs script to handle two different conditions, building 
a setup on a normal developer's machine and building a setup on a TFS build 
agent. The problem is that the TFS build agent copies the products of a 
solution to a binaries folder while a normal developer's build does not. It 
occurred to me that the easiest way to handle the problem would be to simply 
put an environmental variable on the TFS build agent's machine to identify it 
as a TFS build agent and if this environmental variable was found then to use a 
different path to find the source. That's the theory, anyway. The practice has 
proven to be puzzling since nothing seems to work the way that I'd expected.

My first attempt looked like this:
<?if $(env.IsTfsBuildAgent) = "yes" ?>
    <?define SourcePath = ".\..\..\binaries" /> <?else ?>
    <?define SourcePath = "..\bin\$(var.Configuration)" /> <?endif ?>

This seemed to work on the TFS build agent but failed on the development 
machine because IsTfsBuildAgent is not present. OK, fine, let's try a simple 
presence/absence.

<?ifdef $(env.IsTfsBuildAgent) ?>
    <?define SourcePath = "..\..\..\binaries" /> <?else ?>
    <?define SourcePath = "..\bin\$(var.Configuration)" /> <?endif ?>

I built the setup on my development machine and it worked. Great. Then, to 
simulate building on the TFS build agent, I added an environmental variable 
IsTfsBuildAgent, set its value to 'yes' and restarted VS with the expectation 
that the build would fail with 'cannot find ..\..\..\binaries\whatever' but 
instead it compiled a setup program without issue.

Clearly, there's something here that I'm not getting right. Can someone please 
explain how to perform logical operations based upon the content of 
environmental values?




--
View this message in context: 
http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/How-to-detect-an-environmental-variable-s-value-tp7589501.html
Sent from the wix-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register > 
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to