powershellwixwindows-installerwix4

WiX v4 properties set in ui not being resolved in Custom Action


I have the following problem:

I have a custom deferred action which should run a powershell command, but it does not resolve the properties given in the value attribute of my SetProperty element.

I set the properties provided to the command in my ui. I have logged my installation and I can see that it is setting it. But apparently it gets reset somewhere during some action.

This is how I set the property:

<Property Id="LINKDOCUMENTS" Value="QUADDOCUMENTFODLER" />

QUADDOCUMENTFOLDER is set in another .wxs file, with a directory element.

This is my code for the custom action:

<SetProperty Id="CreateSymbolicLinks"
Value="&quot;powershell.exe&quot; -Command &quot;New-Item -ItemType Junction -Path 'C:\inetpub\wwwroot\QUADonline.Server\wwwroot\QUAD Dokumente' -Target &quot;[LINKDOCUMENTS]&quot;"
Before="CreateSymbolicLinks"
Sequence="execute" />

<CustomAction Id="CreateSymbolicLinks"
    BinaryRef="Wix4UtilCA_$(sys.BUILDARCHSHORT)"
    DllEntry="WixQuietExec"
    Execute="deferred"
    Impersonate="no"
    Return="check"
/>

<InstallExecuteSequence>
    <Custom Action="CreateSymbolicLinks" After="InstallFiles" />
</InstallExecuteSequence>

For the UI i basically copied the InstallDirDlg Dialog, changed the names and added more than one directory that i can choose. It works good and as i said the log file shows that its getting set.

This is a a line from my log after the Install action is started:

[13:43:41:387]: PROPERTY CHANGE: Adding QUADDOCUMENTFODLER property. Its value is 
'C:\Dokumente\'.

At the ProcessComponents action, I have this entry:

MSI (s) (20:80) [13:43:43:425]: Dir (source): Key: QUADDOCUMENTFODLER   , Object: C:\ProgramData\Package Cache\{625F85C0-BEBE-4104-9EE7-9E01B42F3BEA}v1.0.17\   ,    LongSubPath: inetpub\wwwroot\QUADonline.Server\wwwroot\QUAD Dokumente\ , ShortSubPath:    inetpub\wwwroot\da7qkhgo\wwwroot\hvwc3pl0\

And then after InstallFiles as specified in my action it executes my custom action and this is what the WixQuietExec in my log says:

WixQuietExec:  New-Item : Cannot find path 'C:\Windows\system32\QUADDOCUMENTFODLER' because 
WixQuietExec:  it does not exist.

Did I maybe just do something wrong with the syntax?

EDIT

I tried to set the After attribute in SetProperty element to "CostFinalize", because that is the last place in my log where I can see that my path is set properly. I also added a '#' before my property (so [#LINKDOCUMENTS]) in the value attribute. Neither of those helped. Now the string for the path is just empty in the log.


Solution

  • The problem was, that i had to put the directory id into the brackets like this [QUADDOCUMENTFODLER] not the property id.