安装程序按顺序设置属性

时间:2018-04-03 10:35:32

标签: wix windows-installer

我收到的WiX代码使用了讨论VersionNT MSI property on Windows 10

中的方法

我的产品.wxs:

    <!-- begin hack - detect windows 10 -->
    <!-- Check if system is windows 10: https://stackoverflow.com/questions/31932646/versionnt-msi-property-on-windows-10 -->
    <Property Id="WIN10FOUND">
      <DirectorySearch Id="searchSystem" Path="[SystemFolder]" Depth="0">
        <FileSearch Id="searchFile" Name="advapi32.dll" MinVersion="6.3.10000.0"/>
      </DirectorySearch>
    </Property>

    <SetProperty Action="SetIsWindow10False"  Id="ISWIN10" After="FindRelatedProducts" Value="0"><![CDATA[WIN10FOUND = ""]]></SetProperty>
    <SetProperty Action="SetIsWindow10True"  Id="ISWIN10" After="FindRelatedProducts" Value="1"><![CDATA[WIN10FOUND <> ""]]></SetProperty>
    <!-- end hack - detect windows 10 -->

    <SetProperty Action="SetMyDriverPathToInstallDir"  Id="MYDRRVPATH" After="FindRelatedProducts" Value=""><![CDATA[ISWIN10 <> 1]]></SetProperty>
    <SetProperty Action="SetMyDriverPathToInstallDir_Win10"  Id="MYDRVPATH" After="FindRelatedProducts" Value="MyDrvDriverWin10\"><![CDATA[ISWIN10 = 1]]></SetProperty>

...

    <InstallExecuteSequence>
...
      <Custom Action="InstallMyDriverDriver" Before="InstallFinalize"><![CDATA[(NOT Installed AND NOT REMOVE) AND VDIENV <>"1" AND NOQOS <> "1" AND ISWIN10 = 0]]></Custom>
      <Custom Action="InstallMyDriverDriver10" Before="InstallFinalize"><![CDATA[(NOT Installed AND NOT REMOVE) AND VDIENV <>"1" AND NOQOS <> "1" AND ISWIN10 = 1]]></Custom>
...
    </InstallExecuteSequence>

但是从安装程序日志中我看到这些属性的顺序是颠倒的

MSI (s) (FC:A4) [16:19:02:683]: Doing action: SetMyDriverPathToInstallDir
MSI (s) (FC:A4) [16:19:02:683]: Note: 1: 2205 2:  3: ActionText 
Action ended 16:19:02: SetCredentialFilter. Return value 1.
Action start 16:19:02: SetMyDriverPathToInstallDir.
MSI (s) (FC:A4) [16:19:02:684]: Skipping action: SetMyDriverPathToInstallDir_Win10 (condition is false)
MSI (s) (FC:A4) [16:19:02:684]: Doing action: SetIsWindow10False
MSI (s) (FC:A4) [16:19:02:684]: Note: 1: 2205 2:  3: ActionText 
Action ended 16:19:02: SetMyDriverPathToInstallDir. Return value 1.
MSI (s) (FC:A4) [16:19:02:685]: PROPERTY CHANGE: Adding ISWIN10 property. Its value is '0'.
Action start 16:19:02: SetIsWindow10False.
MSI (s) (FC:A4) [16:19:02:685]: Skipping action: SetIsWindow10True (condition is false)
MSI (s) (FC:A4) [16:19:02:685]: Skipping action: SetUpgrading (condition is false)
MSI (s) (FC:A4) [16:19:02:685]: Doing action: SetVersion
MSI (s) (FC:A4) [16:19:02:685]: Note: 1: 2205 2:  3: ActionText 
Action ended 16:19:02: SetIsWindow10False. Return value 1.
...
MSI (s) (FC:A4) [16:19:02:695]: PROPERTY CHANGE: Adding WIN10FOUND property. Its value is 'C:\Windows\SysWOW64\advapi32.dll'.

即。首先定义WIN10FOUND但最后调用 draiver的路径最后定义,但先调用

因此,Win10没有更正驱动程序的安装路径,并且存在一些问题。

有人可以帮我理解安装程序以不正确的顺序设置属性的原因吗?

2 个答案:

答案 0 :(得分:2)

我猜您的问题是由于您使用它来设置所有属性而引起的。

After="FindRelatedProducts"

假设这是您的初始执行顺序:

.
.
FindRelatedProducts

然后你说:

<SetProperty Action="SetIsWindow10False"  Id="ISWIN10" After="FindRelatedProducts" Value="0"><![CDATA[WIN10FOUND = ""]]></SetProperty>

你执行序列将是这样的:

.
.
FindRelatedProducts
SetIsWindow10False

然后你说:

<SetProperty Action="SetMyDriverPathToInstallDir_Win10"  Id="MYDRVPATH" After="FindRelatedProducts" Value="MyDrvDriverWin10\"><![CDATA[ISWIN10 = 1]]></SetProperty>

你执行序列将是这样的:

.
.
FindRelatedProducts
SetMyDriverPathToInstallDir_Win10
SetIsWindow10False

最后你的执行顺序是这样的:

.
.
FindRelatedProducts
SetMyDriverPathToInstallDir_Win10
SetMyDriverPathToInstallDir
SetIsWindow10True
SetIsWindow10False

如果你需要一个特定的序列,那么尝试这样的事情:

<SetProperty Action="SetIsWindow10False"  Id="ISWIN10" After="FindRelatedProducts" Value="0"><![CDATA[WIN10FOUND = ""]]></SetProperty>
<SetProperty Action="SetIsWindow10True"  Id="ISWIN10" After="SetIsWindow10False" Value="1"><![CDATA[WIN10FOUND <> ""]]></SetProperty>
<!-- end hack - detect windows 10 -->

<SetProperty Action="SetMyDriverPathToInstallDir"  Id="MYDRRVPATH" After="SetIsWindow10True" Value=""><![CDATA[ISWIN10 <> 1]]></SetProperty>
<SetProperty Action="SetMyDriverPathToInstallDir_Win10"  Id="MYDRVPATH" After="SetMyDriverPathToInstallDir" Value="MyDrvDriverWin10\"><![CDATA[ISWIN10 = 1]]></SetProperty>

这将导致类似这样的事情:

.
.
FindRelatedProducts
SetIsWindow10False
SetIsWindow10True
SetMyDriverPathToInstallDir
SetMyDriverPathToInstallDir_Win10

要检查序列的执行方式,可以使用Orca打开安装程序,这是查看安装程序内部的最佳工具。

答案 1 :(得分:1)

我几周前在这个问题上写了这个答案: Windows 10 not detecting on installshield 。我想这个链接答案中描述的WindowsBuild property是(目前)确定你是否在Windows 10上的一种方法。列出的其他选项也可能有效 - 我只是没有对它们进行过多次测试。我不确定你的需求是什么。

如其他地方所述,您不应再检查操作系统版本,而是检查您需要的操作系统功能(可能已被管理员禁用)。另一个例子证明理论上理论和实践之间应该没有区别,但实际上存在差异。

我将与其他人一起检查如何正确检查这些Windows 10功能。我已经过时了。