简体   繁体   中英

Wix RegistryValue that references installer property always empty

I am trying to write the MediaSourceDir to the registry on the application install, and it is always inserting an empty value. I am successfully able to write the SourceDir to the registry on install, I have the following in my .wxs file:

<RegistryValue Type="string" Name="MediaSourceDir" Value="[MediaSourceDir]" />
<RegistryValue Type="string" Name="SourceDir" Value="[SourceDir]" />

I run the installer with verbose logging and below are some interesting pieces:

MSI (c) (70:48) [16:30:17:332]: PROPERTY CHANGE: Adding SourceDir property. Its value is 'D:\'.
MSI (c) (70:48) [16:30:17:332]: PROPERTY CHANGE: Adding SOURCEDIR property. Its value is 'D:\'.
MSI (c) (70:48) [16:30:17:332]: PROPERTY CHANGE: Adding MediaSourceDir property. Its value is '1'.

So it looks like it is properly fetching the necessary installer properties. But then later in the log file when it is adding the values to the registry it reports the following:

MSI (s) (C4:F0) [16:30:31:525]: Executing op: RegAddValue(Name=MediaSourceDir,,)
MSI (s) (C4:F0) [16:30:31:530]: Executing op: RegAddValue(Name=SourceDir,Value=D:\,)

As you can see, the value for the MediaSourceDir key is empty. I am confused as to why this doesn't work when I am doing something so similar for the SourceDir and it works seamlessly. Any insight would be appreciated.

Though obviously clear to you, I should point out (for others) that MediaSourceDir will only be set when you install from removable media (CD/DVD/USB, etc...). Just so that is clear. Otherwise it is blank / unset and trying to persist it will yield an empty string.

However, I too see the problem whereby MediaSourceDir isn't possible to persists like you do for SourceDir. I got it working by assigning the value of MediaSourceDir to a public property using a SetProperty custom action, but it did not work when the setup was run silently.

<Property Id='MYPROPERTY' Secure='yes' />
<SetProperty Id="MYPROPERTY" After="FindRelatedProducts" Value="[MediaSourceDir]" Sequence="first" />

<..>

<Component Feature="ProductFeature">
   <RegistryValue Root='HKLM' Key='SOFTWARE\Wix\DemoRememberProperty'
                  Name='MediaSourceDirMYPROPERTY' Value='[MYPROPERTY]'
                  Type='string' />
<..>

</Component>

We need to know what the purpose of the persisting is? Could you use the MSI API instead to figure out whether the installation source drive is a removable drive?

Will have a look at this again later. WiX's Remember Property Pattern .

I deleted a whole segment on Private and PUBLIC properties and how they are handled differently in deferred mode, not sure if this is already something you have studied, but it seemed not too necessary.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM