Bill Zee
Bill Zee

Reputation: 17

Prevent removal of bootstrapper

I have a custom bootstrapper that allows the user to uninstall components of the installation or the entire installation. In either situation, the bootstrapper is removed and no longer available in 'Programs and Features'. Is there a way I can prevent the bundle from being removed if I know the user is just uninstalling a component of the installation?

I thought maybe I could set the installation state to modify but I don't see a way to do that.

Upvotes: 0

Views: 64

Answers (1)

John Wright
John Wright

Reputation: 4607

During the Plan phase, you need to handle a handful of events to set the State you want for each MsiFeature and Package within your bundle.

For each wix msifeature and/or package the user is changing, you'll need to set the State value of the event args to AddLocal or Remove for features, and Present or Absent for packages during the planning phase event handlers (BootstrapperApplication.PlanPackageBegin and BootstrapperApplication.PlanMsiFeature). For any remaining unchanged, set the state to None.

Then, when you call Engine.Plan(...), you'll need to provide a LaunchAction value of Modify or Install if you want the bootstrapper to exist after the run, or Uninstall if you want to have the bootstrapper removed. I suspect this is where you're having issues -- check what value you're passing to Plan()

I wrote a series of blog posts you may find helpful (particularly part 5): Writing Your Own .NET-based Installer with WiX

Upvotes: 2

Related Questions