简体   繁体   English

引用安装程序属性的 Wix RegistryValue 始终为空

[英]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.我正在尝试将 MediaSourceDir 写入应用程序安装的注册表中,并且它始终插入一个空值。 I am successfully able to write the SourceDir to the registry on install, I have the following in my .wxs file:我能够在安装时成功地将 SourceDir 写入注册表,我的 .wxs 文件中有以下内容:

<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.如您所见,MediaSourceDir 键的值为空。 I am confused as to why this doesn't work when I am doing something so similar for the SourceDir and it works seamlessly.我很困惑,为什么当我为 SourceDir 做类似的事情时这不起作用,并且它可以无缝地工作。 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...).尽管您显然很清楚,但我应该指出(对于其他人) MediaSourceDir仅在您从可移动媒体(CD/DVD/USB 等)安装时才会设置。 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.但是,我也看到了 MediaSourceDir 不可能像您对 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.我通过使用 SetProperty 自定义操作将 MediaSourceDir 的值分配给公共属性来使其工作,但是当安装程序静默运行时它不起作用。

<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?您能否改用 MSI API 来确定安装源驱动器是否是可移动驱动器?

Will have a look at this again later.稍后再看看这个。 WiX's Remember Property Pattern . WiX 的记住属性模式

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.我删除了 Private 和 PUBLIC 属性上的整个段以及它们在延迟模式下的处理方式,不确定您是否已经研究过这些内容,但这似乎没有太大必要。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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