kudlatiger
kudlatiger

Reputation: 3278

How do I stop removal of files during uninstallation using Wix

When uninstalling my application, I'd like to configure the Wix setup to NOT to remove few files that were added as part of the installation. It seems like the uninstaller removes all the files that were originally installed from the MSI file. How do I do that?

Here are my files which I wish to keep it forever

<Binary Id="RootCABinary" SourceFile="Assets\Certificates\RootCA.cer" />
<Binary Id="SubCABinary" SourceFile="Assets\Certificates\SubCA.cer" />

I have used WixIIsExtension.dll to install these certificates to the windows store.

Upvotes: 2

Views: 969

Answers (2)

Stein &#197;smul
Stein &#197;smul

Reputation: 42136

Overwrite: Is it important that the file never gets overwritten? If so, add "Never Overwrite" to your component. WiX attribute: NeverOverwrite="yes". Remember to test upgrade scenarios!


Permanent Component: As stated by Pavel, you can set a component permanent:

<Component Permanent="yes">
    <File Source="License.rtf" />
</Component>

Blank GUID: Another way to do it is to set a blank component GUID. It essentially means "install and then leave alone". No repair or uninstall should be done (remember to add NeverOverwrite="yes" if the file should never be overwritten):

<Component Guid="" Feature="MainApplication">
    <File Source="SubCA.cer" KeyPath="yes" />
</Component>

Read-Only Copy: I sometimes install files to a per-machine path (for example somewhere under program files) and then copy them to a per-user location (somewhere in the user-profile) on application launch, and then do operations on them that entail that the files should not be deleted. This is good in cases where you want to do something that change the files in question (they need to be writable). Then it is good to "untangle" them from deployment concerns (files will not be meddled with by installer operations at all - the installer has no knowledge of them). The original read-only copy installed to program files can be uninstalled though (no longer needed?).


Other approaches: You can also create such files using custom actions during installation (usually text files only), you can download the file in question from your web site on application launch (makes the file easy to manage and update / replace? Vulnerable to connection problems - firewalls, etc...) and the application can create the file using "internal defaults" in the main executable on launch. And there are no doubt further approaches that I can't recall.

Upvotes: 3

Pavel Anikhouski
Pavel Anikhouski

Reputation: 23228

Put your binaries in a separate WiX component and make it permanent. Have a look at this thread as well

Upvotes: 1

Related Questions