【发布时间】:2019-04-11 04:49:47
【问题描述】:
我正在使用 wix 在 Visual Studio 中为我的应用程序创建安装程序。 我需要在安装(我已经开始工作)之后运行安装后可执行文件,并在卸载之前运行预卸载可执行文件。 所有这些可执行文件都需要提升权限才能运行(我的应用程序、安装后和卸载前)。
我搜索了网络和堆栈溢出,发现了许多与此相关的帖子,但似乎没有一个解决方案有效。可执行文件根本无法运行,或者在卸载时出现错误
There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor.
这是我的目录布局
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="ROOTDIRECTORY" Name="MyCompany" >
<Directory Id="FOLDERONE" Name="FolderOne" />
<Directory Id="UTILITYFOLDER" Name="Utility" />
</Directory>
</Directory>
</Directory>
</Fragment>
还有我的文件布局的 sn-p
<Fragment>
<DirectoryRef Id="UTILITYINSTALLFOLDER">
<Component Id="cmpPreInstallId" Guid="{56DC3D0A-E887-4A94-95B3-72825310DC5D}">
<File Id="filPreInstallId" KeyPath="yes" Source="path_to\PreUninstall.exe" />
</Component>
<Component Id="cmpPosUninstallId" Guid="{DE1DE45E-4D7C-4884-BA3E-EC078E265B7C}">
<File Id="filPostUninstallId" KeyPath="yes" Source="path_to\PostInstall.exe" />
</Component>
<!-- obviously there are other files/components -->
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="UtilityPublishedComponents">
<ComponentRef Id="cmpPreInstallId" />
<ComponentRef Id="cmpPosUninstallId" />
</ComponentGroup>
</Fragment>
在我的 Product.wxs 中
<Product ...>
<!-- The only way I found that actually worked to run the post install was -->
<UI>
<UIRef Id="WixUI_Minimal" />
<Publish Dialog="ExitDialog"
Control="Finish"
Event="DoAction"
Value="PostInstallExe">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
</UI>
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Perform post-install operations." />
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOX" Value="1"/>
<Property Id="WixShellExecTarget" Value="[#filPostUninstallId]" />
<CustomAction Id="PostInstallExe"
BinaryKey="WixCA"
DllEntry="WixShellExec"
Impersonate="yes" />
<!-- this does not work to run the pre-uninstall -->
<CustomAction Id="EXECUTE_BEFORE_UNINSTALL"
Return="check"
Impersonate="yes"
Execute="immediate"
Directory="UTILITYINSTALLFOLDER"
ExeCommand="PreUninstall.exe" />
<InstallExecuteSequence>
<Custom Action="EXECUTE_BEFORE_UNINSTALL" Before="RemoveFiles">Installed AND NOT REINSTALL</Custom>
</InstallExecuteSequence>
<!-- other stuff plus the feature -->
</Product>
任何有经验的人都知道这可能会出错吗?
我已经尝试了 CustomAction 返回、模拟、执行等的许多变体
【问题讨论】:
标签: wix