c# – Creating your own Windows installer

Question:

Most installers are created using various utilities (WiX, Inno Setup, Install Shield, etc.). I am interested in creating an installer with its own UI, as is done, for example, in Kaspersky Anti-Virus and Visual Studio.

Is it possible to use the .NET Framework in such cases or would you need pure C ++? Will no one have links to explanations of what exactly the installer should do?

Answer:

To create a custom UI via WIX, you can use Burn / BootstrapperApplication – the standard way to create wrappers on top of MSI.

An example for WPF is in the WiX src package , in the src\Setup\WixBA . It is screwed (judging by the documentation) like this:

  1. Собирается DLL с UI (WixBA из примеров)
  2. В bundle.wxs (есть в стандартном шаблоне WiX для VS) добавляется

    <BootstrapperApplicationRef Id="ManagedBootstrapperApplicationHost" >
      <Payload SourceFile="$(var.InstallSourceResources)Bootstrapper\WixBA.dll"/>
      <Payload Id="FusionInstallUX.config"
           SourceFile="$(var.InstallSourceResources)Bootstrapper\WixBA.BootstrapperCore.config"
           Name="BootstrapperCore.config" Compressed="yes"/>
    </BootstrapperApplicationRef>
    

The custom UI itself is just a subclass of BootstrapperApplication in an assembly marked with the BootstrapperApplicationAttribute .

Config example:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <sectionGroup
            name="wix.bootstrapper"
            type="Microsoft.Tools.WindowsInstallerXml.Bootstrapper.BootstrapperSectionGroup, BootstrapperCore">

            <section
                name="host"
                type="Microsoft.Tools.WindowsInstallerXml.Bootstrapper.HostSection, BootstrapperCore" />
        </sectionGroup>
    </configSections>

    <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0" />
    </startup>

    <wix.bootstrapper>
        <host assemblyName="FusionInstallUX">
            <supportedFramework version="v4\Full" />
            <supportedFramework version="v4\Client" />
        </host>
    </wix.bootstrapper>
</configuration>

More detailed examples:


An alternative option without burn / .NET, which (in theory) can be screwed onto any msi-installer, is to register the EmbeddedUI DLL in the MsiEmbeddedUI table. A basic example and dll requirements are outlined in MSDN, Using an Embedded UI .

Scroll to Top