如何更改 NGen 在 WiX MSI 包中运行时显示的文本

wig*_*igy 4 wix ngen

我们在安装过程中使用 NGen 来优化应用程序的启动时间。

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"
     xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension">
  ...
  <File Id="File.$(var.ProjectName.TargetName).exe" Source="$(var.ProjectName.TargetPath)" KeyPath="yes">
    <netfx:NativeImage Id="ngen.File.$(var.ProjectName.TargetName)" Platform="$(var.NgenPlatform)" Priority="0" AppBaseDirectory="INSTALLLOCATION"/>
  </File>
  ...
</Wix>
Run Code Online (Sandbox Code Playgroud)

在安装生成的 MSI 时,与其他步骤相比,“删除备份文件”步骤花费了非常长的时间。深入研究,我们发现当时 NGen 正在运行。

我们怎么能在那里写点别的东西,比如“我们现在在你的应用程序每次启动时为你节省了很多时间”?

小智 5

实际上有更好的方法,因为 NetFx WiX 扩展中有两个操作 NetFxExecuteNativeImageCommitInstall(在启用回滚的情况下调用)和 NetFxExecuteNativeImageInstall(在禁用回滚的情况下)。

<UI>
    <ProgressText Action="NetFxExecuteNativeImageInstall">Speeding up your application</ProgressText>
</UI>
<InstallExecuteSequence>
    <Custom Action="NetFxExecuteNativeImageCommitInstall" After="NetFxExecuteNativeImageUninstall">0</Custom>
    <Custom Action="NetFxExecuteNativeImageInstall" After="NetFxExecuteNativeImageCommitInstall" />
</InstallExecuteSequence>
Run Code Online (Sandbox Code Playgroud)