Question

I've been trying to figure out why my condition isn't working for my SetDirectory. I haven't been able to find any examples of anyone actually doing this, only that it is possible to do so, according to the WiX documentation.

I've tried the following:

<SetDirectory Id="INSTALLLOCATION" Value="TEST">ComputerName=LJPRESCOTT1</SetDirectory>

This compiles, but gets ignored at runtime. The files end up getting installed straight on the C:\ Drive, and not in C:\TEST like I'm aiming for.


and

<SetDirectory Id="INSTALLLOCATION" Value="TEST">[ComputerName]=LJPRESCOTT1</SetDirectory>

This doesn't compile and throws a "Bad conditional string" error.


If I do this, it creates a directory named LJPRESCOTT1 as expected:

<SetDirectory Id="INSTALLLOCATION" Value="[ComputerName]" />

So I know the Comp Name is correct.

Am I doing something wrong here, or is this not possible?

Thanks!

Was it helpful?

Solution

You use the syntax [ComputerName] only when you are doing formatting, or using values that are of type Formatted, hence the syntax error in the second example.

But in the first example what you are doing is comparing the value of the ComputerName property with the value of the LJPRESCOTT1 (public) property, which I imagine always evaluates to false. If you want to compare ComputerName to a hard string value you need some quotes:

ComputerName="LJPRESCOTT1"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top