How to make WiX leave files after uninstall?

2019-03-17 09:31发布

Is there a way to NOT delete files after an uninstall?

4条回答
虎瘦雄心在
2楼-- · 2019-03-17 09:53

Another way to prevent Windows Installer from deleting the component on uninstall is to set a blank or empty component GUID. This will cause the component to be installed but it will never be tracked or uninstalled.

See the MSI SDK documentation: "...if this column (ComponentId) is null the installer does not register the component and the component cannot be removed or repaired by the installer. This might be intentionally done if the component is only needed during the installation, such as a custom action that cleans up temporary files or removes an old product. It may also be useful when copying data files to a user's computer that do not need to be registered."

查看更多
一纸荒年 Trace。
3楼-- · 2019-03-17 09:56

Compliments of Phil Wilson from wixusers mailing-list:

See the MSI SDK docs for the Component table - set the Component guid to be null (empty). The effect of this is that the component isn't registered (so it can't be repaired) and it won't be uninstalled.

查看更多
Juvenile、少年°
4楼-- · 2019-03-17 09:59

Set the Component value Permanent="yes" like so:

<Component Id="LicenseDoc" Guid="*" Permanent="yes">
    <File Id ="License.rtf" Source="$(var.SolutionDir)Installer\License.rtf" />
</Component>
查看更多
趁早两清
5楼-- · 2019-03-17 10:11

I know this question is old, but I just stumbled across it as I was looking for a way for my installer to install missing fonts, but not uninstall them when the application is uninstalled. Hope it helps someone else who may come across this question. I was a bit uncomfortable with both of the solutions provided (blank/empty Guid or set the component to permanant). So I came up with this, which worked for me:

<Feature Id="myFonts" Title="Application Fonts" Level="1">
  <ComponentGroupRef Id="Component_group_with_fonts_to_install" />
  <Condition Level="0">
    <![CDATA[REMOVE = "ALL"]]>
  </Condition>
</Feature>

This way the font feature is installed, but when being uninstalled, the feature's level is set to 0, so it is left alone.

查看更多
登录 后发表回答