Features allow you to group files, folders, or shortcuts into selectable components. When features are used, PSMSI defaults to the WiX feature tree UI, allowing users to choose what to install.
Feature States (-DefaultState):
Install: Installed by default.Absent: Not selected by default, but available for user selection.CompleteOnly: Installed only during a 'Complete' installation.Disabled: Prevents the feature from being installed.
Assigning Content to Features:
You can wrap content in New-InstallerFeature or assign an existing item to a feature using the -Feature parameter on the item (e.g., on a shortcut).
New-Installer -ProductName "My Product" -UpgradeCode 'GUID' -Content {
New-InstallerDirectory -PredefinedDirectory "ProgramFilesFolder" -Content {
New-InstallerDirectory -DirectoryName "My App" -Id "INSTALLFOLDER" -Content {
# A required feature
New-InstallerFeature -Id "Core" -Title "Core application" -Required -Content {
New-InstallerFile -Source . extbackslash{}app.exe -Id "AppExe"
}
# An optional feature
New-InstallerFeature -Id "Samples" -Title "Sample files" -DefaultState Absent -Content {
New-InstallerDirectory -DirectoryName "Samples" -Content {
New-InstallerFile -Source . extbackslash{}sample.ps1
}
}
}
}
}