Skip to content

Create a MSI with WXS template

Volker Berlin edited this page Mar 20, 2023 · 3 revisions

The Wix Toolset has many more features as the Gradle Setup Builder Plugin. Or you want change some default behavior of SetupBuilder.

msi {
  wxsTemplate = "${projectdir}/template.wxs"
}

The template file can look like:

<?xml version="1.0" encoding="UTF-8"?>
<Wix>
  <Product>
  </Product>
</Wix>

The plugin will patch the template. If an attribute of a node is already set then it will not change. If a needed node does not exists then it will create. Depending if it is a single node or if there are multiple nodes are possible the node search use a unique ID or not. The resulting template.wxs with contains all the used IDs. You can find it after the build in the folder build/temp/msi/template.wxs.

Samples:

<?xml version="1.0" encoding="UTF-8"?>
<Wix>
  <Product>
    <!-- https://msdn.microsoft.com/en-us/library/windows/desktop/aa371182(v=vs.85).aspx -->
    <!-- need to override files also on downgrade -->
    <Property Id="REINSTALLMODE" Value="amus"/>
  </Product>
</Wix>
<?xml version="1.0" encoding="UTF-8"?>
<Wix>
  <Product>
    <!-- run the uninstaller action with current user scope without elevated privileges -->
    <CustomAction Id="runBeforeUninstall" Impersonate="yes"/>
  </Product>
</Wix>