/salt-windows-msi

Windows MSI installer build toolkit

Primary LanguageC#Apache License 2.0Apache-2.0

Windows MSI installer build toolkit

This project creates a Salt Minion msi installer using WiX.

Features

  • Change installation directory BLOCKED BY issue #38430
  • Uninstall leaves configuration, remove with msiexec /x KEEP_CONFIG=0
  • Logging into %TEMP%\MSIxxxxx.LOG, options with msiexec /l
  • Upgrades NSIS installations

Minion-specific msi-properties:

Property Default Comment
INSTALLFOLDER c:\salt\ Where to install the Minion DO NOT CHANGE
MASTER_HOSTNAME salt The master hostname
MINION_HOSTNAME %COMPUTERNAME% The minion id
START_MINION_SERVICE 0 (false) Whether to start the salt-minion service after installation
KEEP_CONFIG 1 (true) keep configuratioin on uninstall. Only from command line

A kept configuration is reused on installation into its location.

On unattended install ("silent install")

An msi allows you to install unattended ("silently"), meaning without opening any window, while still providing customized values for e.g. master hostname, minion id, installation path, using the following command line:

msiexec /i *.msi /qb! PROPERTY=VALUE PROPERTY=VALUE

Requirements

  • .Net 2.0, or higher

Build Requirement

Build procedure

cd c:\git\salt
git checkout v2016.11.3
    # Apply https://github.com/saltstack/salt/pull/39274  (msi numbering scheme in version.py)
    # git status must only show `modified: salt/version.py`
cd c:\git\salt\pkg\windows
build.bat
cd c:\git\salt-windows-msi
yclean.cmd
ybuild.cmd
    # Expect 84 ICE03 warnings

MSBuild

General command line:

msbuild msbuild.proj [/t:target[,target2,..]] [/p:property=value [ .. /p:... ] ]

A 'help' target is available which prints out all the targets, customizable properties, and the current value of those properties:

msbuild msbuild.proj /t:help

Directory structure

  • msbuild.d/: build the installer:
    • BuildDistFragment.targets: find files (from the extracted distribution?).
    • DownloadVCRedist.targets: (ORPHANED) download Visual C++ redistributable.
    • Minion.Common.targets: set version and platform parameters.
  • wix.d/: installer sources:
    • MinionConfigurationExtension/: C# for custom actions:
      • MinionConfiguration.cs
    • MinionEXE/: (ORPHANED) create a bundle.
    • MinionMSI/: create a msi:
      • dist-$(TargetPlatform).wxs: found files (from the distribution zip file?).
      • MinionConfigurationExtensionCA.wxs: custom actions boilerplate.
      • MinionMSI.wixproj: msbuild boilerplate.
      • Product.wxs: main file.
      • service.wxs: Windows Service (using nssm.exe).
      • SettingsCustomizationDlg.wxs: Dialog for the master/minion properties.
      • WixUI_Minion.wxs: UI description.
  • msbuild.proj: main msbuild file.
  • wix.sln: Visual Studio solution file, needed to build the installer.

Extending

Additional configuration manipulations may be able to use the existing MinionConfigurationExtension project. Current manipulations read the value of a particular property (e.g. MASTER_HOSTNAME) and apply to the existing configuration file using a regular expression replace. Each new manipulation will require changes to the following files:

  • MinionConfiguration.cs: a new method (i.e. new custom action).
  • MinionConfigurationExtensionCA.wxs: a <CustomAction /> entry to make the new method available.
  • Product.wxs: a <Custom /> entry in the <InstallSequence /> to make the configuration change.
  • Product.wxs: a <Property /> entry containing a default for the manipulated configuration setting.
  • README.md: alter this file to explain the new configuration option and log the property name.

If the new custom action should be exposed to the UI, additional changes are required:

  • SettingsCustomizatonDlg.wxs: There is room to add 1-2 more properties to this dialog.
  • WixUI_Minion.wxs: A <ProgressText /> entry providing a brief description of what the new action is doing.

If the new custom action requires its own dialog, these additional changes are required:

  • The new dialog file.
  • WixUI_Minion.wxs: <Publish /> entries hooking up the dialog buttons to other dialogs. Other dialogs will also have to be adjusted to maintain correct sequencing.
  • MinionMSI.wixproj: The new dialog must be added as a <Compile /> item to be included in the build.

On versioning

Microsoft defines software versions as major.minor.build with maximum values of 255.255.65535.

This definition lacks the micro field used in Salt 2016.11.3 (or Python 3.6.2) and one has to make a decision for the micro field:

  1. Deviate from the Microsoft definition and use the third field as micro
  2. Stick with the Microsoft definition and discard the micro field.

I see no value in sticking with the Microsoft definition and chose 1.

Microsoft major version must be smaller than 256, therefore I use the short year (16 instead of 2016).

In WiX terms: when DisplayVersion is 2016.11.3, InternalVersion becomes 16.11.3.

InternalVersion is displayed in the Version column of "Programs and Features" (formally "Add remove program") (appwiz.cpl)