Register a SA Forums Account here!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us $3,400 per month for bandwidth bills alone, and since we don't believe in shoving popup ads to our registered users, we try to make the money back through forum registrations.
  • Locked thread
Seaside Loafer
Feb 7, 2012

Waiting for a train, I needed a shit. You won't bee-lieve what happened next

Never realised MSI itself was such a dark art, and top of it the bloody WiX, only delved into last week.

Simple question that if answered would make all my dreams come true (well make me be able to finish the bloody nearly finished setup regime for software product)

I have a c# custom action to select an option and enter some text, how can I reference and act on variables in it in the wxs. Really id like to optionally install different components depending on the select but I cant seem to reference the property returned in session.

Here is the property and the DLL binding sample from the wxs
    <Property Id="THING_INSTALL_TYPE" Value="Default" />
    <Binary Id="THINGSetupCustomActionsDLL" SourceFile=".\Compiled\THINGSetupCustomActions.CA.dll" />
    <CustomAction Id="SelectClientServerID" BinaryKey="THINGSetupCustomActionsDLL" DllEntry="SelectClientServer" Execute="immediate" Return="check" />
And this bit will happilly run the DLL (and its child winforms)

      <Custom Action="SelectClientServerID" Before="InstallValidate" />
On exit in the custom dll in c# I say:

session["THING_INSTALL_TYPE"] = "Client";
Then in the WXS I want to conditionally install components based on the result, see condition. I have to do it this way because of various reasons but it just doesn't seem to return the property back from the custom action. Any ideas?

            <Component Id='AppComponentID' Guid='xxxxxxxx-3C67-4826-BB16-82DD9D876B29'>
              <File Id='THINGEXEFileID' Name='THING.exe' DiskId='1' Source='.\Compiled\THING.exe' KeyPath='yes'>
                <Shortcut Id="startmenuTHINGLink" Directory="ProgramMenuDir" Name="THINGWorkingDirectory='INSTALLDIR' Icon="THING.exe" IconIndex="0" Advertise="yes" />
                <Shortcut Id="desktopTHING" Directory="DesktopFolder" Name="THING" WorkingDirectory='INSTALLDIR' Icon="THINGApp.exe" IconIndex="0" Advertise="yes" />
              <Condition>THING_INSTALL_TYPE = "Client"</Condition>
Basically it all seems to work (barring things I know need changing) but i cant for life of me work out how to reference a variable from the custom action in the wxs. (Apart from the success fail etc). Banging my loving head against the wall here and would love to open a dialog with a master of installers


Seaside Loafer
Feb 7, 2012

Waiting for a train, I needed a shit. You won't bee-lieve what happened next

If anyone is interested I found the solution from some really nice people on the WiX user mailing list which is at <>

Its to do with the sequence of events. Basically there is an UI sequence and a EXE sequence, both of which may be occurring depending on what you are trying to do. Its documented somewhere but its where to use my event that was my problem.
Changed my custom dll to run before CostInitialize and the properties go back to the wxs because its after that point they get evaluated in the wxs.

I like this thing but bloody hell is it badly documented by the provider/s, basically all the documentation comes from the community. Have to use it, want to use it, but cant figure out how it works in short order if that makes sense. Call me old school if you like but I dont think trying to do something simple rapidly should be some baptism of fire into magic ancient powers.

To be fair ultimately MS not wrapping the MSI stuff in way that makes it easy is to blame I think so im not blaming WiX (And the mailing list people are lovely)

e: id encourage anyone to join that mailing list if you have any problems/questions, the online documentation is loving shocking for a newbie but those guys are great!

Seaside Loafer fucked around with this message at Sep 14, 2017 around 20:06

  • Locked thread