系统相关
首页 > 系统相关> > MSI windows程序安装

MSI windows程序安装

作者:互联网

控制面板里只有一个版本号

安装时采取升级方式,主要关键点有:
1.版本更新;(1.1.1.XXXXX-> 1.1.2.XXXXX)
2.ProductCode变化;(<Product Id="*")
3.UpgradeCode保持不变。(<Upgrade Id="不变")

自定义操作

1.新建C# Custom Action Project for WiX动态库;
2.Setup Project for WiX添加引用;
3.XML编辑;

<Binary Id="SetupCustomClass" SourceFile="$(var.MyInstallerCustomAction.TargetDir)\$(var.MyInstallerCustomAction.TargetName).CA.dll" />
<CustomAction BinaryKey="SetupCustomClass" Id="CustomClassMethod1" DllEntry="CustomClassMethod1" />
<InstallExecuteSequence>
      <Custom Action="CustomClassMethod1" After="InstallInitialize"></Custom>
</InstallExecuteSequence>

CustomClassMethod1里可以直接访问相关属性,比如session["INSTALLFOLDER"]获取安装目录。

自定义操作传递参数

<CustomAction Id="FileRemainderMeasureBefore" Property="FileRemainderMeasure" Value="SomeCustomActionDataKey=$(var.MyClientProject.TargetName)|[INSTALLFOLDER]|[APPLICATIONFOLDER]" />
<CustomAction BinaryKey="SetupCustomClass" Id="FileRemainderMeasure" DllEntry="FileRemainderMeasure" Execute="deferred" Return="check" HideTarget="no" Impersonate="no" />
<InstallExecuteSequence>
      <Custom Action="FileRemainderMeasureBefore" Before="FileRemainderMeasure"></Custom>
      <Custom Action="FileRemainderMeasure" Before="InstallFinalize">REMOVE="ALL"</Custom>
</InstallExecuteSequence>

FileRemainderMeasure方法里,可以在卸载后获取传递的参数,作彻底清理等操作。

string data = session.CustomActionData["SomeCustomActionDataKey"];

因为是延迟操作,当前session不能访问。

InstallExecuteSequence

Installer会按照默认顺序来执行

• AppSearch
• LaunchConditions
• ValidateProductId
• CostInitialize
• FileCost
• CostFinalize
• InstallValidate
• **InstallInitialize**
• ProcessComponents
• UnpublishFeatures
• RemoveRegistryValues
• RemoveShortcuts
• RemoveFiles
• InstallFiles
• CreateShortcuts
• WriteRegistryValues
• RegisterUser
• RegisterProduct
• PublishFeatures
• PublishProduct
• **InstallFinalize**

标签:1.1,自定义,windows,Project,程序安装,session,MSI,XXXXX,WiX
来源: https://www.cnblogs.com/wesson2019-blog/p/14344720.html