![](/img/trans.png)
[英]Wix - Run Custom Action only On Upgrade and Patch Not on Repair/Reinstall
[英]WiX Installer - Environment Variable Removed with Reinstall/Repair
我正在使用 WiX 3.11.1 為 Petrel 插件創建一個 WiX 安裝程序。 Product.wxs 本質上是以下內容,並進行了一些修改:
https://github.com/davidbcc/DeCompactPlugIn/blob/dev/FaciesDecompactorInstaller/Product.wxs
我在向導中添加了一個頁面,用戶可以在其中的編輯框中指定許可證服務器。 根據這些信息,我創建和/或更新了一個環境變量:
<!-- Get the current environment variable if it exists -->
<SetProperty Id="LICENSE_SERVER_ENV_VAR" Value="[%LIC_HOST]" After="LaunchConditions" Sequence="first"></SetProperty>
<snip>
<!-- Validate that the license server name is not empty before proceeding. -->
<Control Type="PushButton" Id="Next" X="239" Y="243" Width="56" Height="17" Default="yes" Text="Next">
<Publish Event="SpawnDialog" Value="ServerNameErrorDlg"><![CDATA[LICENSE_SERVER_ENV_VAR = ""]]></Publish>
<Publish Event="NewDialog" Value="ngenDialog"><![CDATA[LICENSE_SERVER_ENV_VAR <> ""]]></Publish>
</Control>
<snip>
<!-- Install the plugin and set the environment variable -->
<Fragment>
<ComponentGroup Id="PluginComponents" Directory="INSTALLLOCATION">
<Component Id="PetrelPluginPip" Guid="120AF5B9-E751-43F4-AF4C-7DED33C8BEB4">
<Environment Id="LicenseServerEnVar" Action="set" Name="LIC_HOST" System="yes" Permanent="yes" Value="[LICENSE_SERVER_ENV_VAR]"/>
<File Id="PetrelPluginPippip" Source="../OceanPluginPip/bin/$(var.OceanPluginPip.Platform)/$(var.OceanPluginPip.Configuration)/PetrelPluginPip.pip" KeyPath="yes" />
</Component>
</ComponentGroup>
</Fragment>
在初始安裝和通過添加/刪除程序操作時,一切似乎都運行良好。 如果我在那里運行修復,它會靜默運行並且環境變量仍然存在。
但是,安裝后,如果我右鍵單擊安裝程序(實際的.msi 文件),select“安裝”,然后select 維護對話框中的“修復”選項,我go 再次通過向導。 該頁面正確地提取了許可證服務器信息,就像在初始安裝時一樣,但在完成修復后,環境變量將從系統中刪除。
我努力了:
這些都沒有用。
有誰知道為什么通過 MaintenanceDialog 進行修復會導致刪除環境變量? 謝謝。
編輯:添加詳細日志記錄后,修復 output 顯示以下似乎相關的內容:
MSI (s) (60:78) [11:42:25:420]: PROPERTY CHANGE: Adding RestrictedUserControl property. Its value is '1'.
MSI (s) (60:78) [11:42:25:420]: PROPERTY CHANGE: Adding PETRELINSTALLLOCATION property. Its value is 'C:\Program Files\Schlumberger\Petrel 2022\'.
MSI (s) (60:78) [11:42:25:420]: Ignoring disallowed property INSTALLLOCATION
MSI (s) (60:78) [11:42:25:420]: Ignoring disallowed property LICENSE_SERVER_ENV_VAR
MSI (s) (60:78) [11:42:25:420]: Ignoring disallowed property TARGETDIR
Action start 11:42:25: LaunchConditions.
Action ended 11:42:25: LaunchConditions. Return value 1.
MSI (s) (60:78) [11:42:25:468]: Doing action: SetLICENSE_SERVER_ENV_VAR
MSI (s) (60:78) [11:42:25:468]: Note: 1: 2205 2: 3: ActionText
Action start 11:42:25: SetLICENSE_SERVER_ENV_VAR.
MSI (s) (60:78) [11:42:25:469]: Skipping action due to msidbCustomActionTypeFirstSequence option.
Action ended 11:42:25: SetLICENSE_SERVER_ENV_VAR. Return value 0.
為什么該物業不允許維修? 我在初始安裝時沒有看到。 但是我仍然看不到環境變量在哪里被刪除。
在調查了“忽略不允許的屬性”的含義之后,我發現了以下帖子,表明該屬性可能不會傳播到執行序列:
https://stackoverflow.com/a/39227065/4460247
通過添加屬性定義並在填充之前將其標記為“安全”,設置屬性並且不再刪除環境變量。
<Property Id="LICENSE_SERVER_ENV_VAR" Secure="yes"></Property>
<SetProperty Id="LICENSE_SERVER_ENV_VAR" Value="[%LIC_HOST]" After="LaunchConditions" Sequence="first"></SetProperty>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.