Release v1.5.0.0
This release delivers defect fixes and quite a few new features (majority is contributed by @Xaddan).
The most important feature to be aware of is the customization of the ID allocation algorithm. This feature may affect some users so please read about it in more details in the bottom section.
- Added IniFile element support
- Add ProgressText element support
- Add UrlReservation element support
- Add CustomActionRef element support
- Add CustomAction rollback customization
- Issue #201: WixStandardBootstrapperApplication ShowVersion
- Issue #198: Files.AddRange not work; Extension method
AddRangeis renamed inCombine - Issue #208: Unable to sign msi file
- Issue #214: Add InstallPrivileges property to project
- Issue #206: WixQuietExecAction and deferred
- Custom hash based ID-generation algorithm has been embedded as
WixSharp.Project.HashedTargetPathIdAlgorithm - Separated
Project.CustomIdAlgorithmandCompiler.CustomIdAlgorithm - Added
Compiler.AutoGeneration.IsWxsGenerationThreadSafe Compiler.AutoGenerationsettings object made read-only
ID allocation customization
The need for user defined ID allocation algorithm was expressed in the multiple reports. The existing ID auto-generation algorithm exhibited certain practical limitations in some scenarios. While manual ID allocation gives the user the complete control over ID allocation, having a hybrid solution when user has ability to customize the auto-allocation was an attractive option.
Starting from this release user as an ability to provide a customid-allocation algorithm, which is invoked by WixSharp if no explicit Id for the WixEntity is specified:
project.CustomIdAlgorithm =
entity =>
{
if (entity is File file)
{
var target_path = this.GetTargetPathOf(file);
var dir_hash = Math.Abs(target_path.PathGetDirName().GetHashCode32());
var file_name = target_path.PathGetFileName();
return $"File.{dir_hash}.{file_name}"; // pass to default ID generator
}
};WixSharp also provides an alternative ready to go id-allocation algorithm, which addresses the reported limitations. Thus instead of emitting indexed IDs it produces ID with the target path hash for all File entities/elements. Note this feature does not affect user ability to set IDs manually.
// globally via configuration
Compiler.AutoGeneration.LegacyDefaultIdAlgorithm = false;
// for project only via delegate
project.CustomIdAlgorithm = project.HashedTargetPathIdAlgorithm;The feature implementation took into account the community feedback provided via #204.
The new approach is more reliable but it will affect the users who stores the generated WXS files under source control. That's why the new API allows switching back to legacy ID-allocation algorithm if required.
Currently (in this release) the new hash-based algorithm is disabled by default to allow the users some time to get used to the new algorithm. But it will be made enabled by default in the next release.
Support for new WiX elements
Sample for UrlReservation element:
var project =
new Project("MyProduct",
new Dir(@"%ProgramFiles%\My Company\My Product",
new UrlReservation("http://+:2131/url/device_service/",
"*S-1-1-0",
UrlReservationRights.register),
...Sample for IniFile:
var project =
new Project("MyProduct",
new Dir(@"%ProgramFiles%\My Company\My Product",
new File(@"..\Install Files\Files\Bin\MyApp.exe")),
new Property("IP_ADRESS", "127.0.0.1"),
new IniFile("config.ini", "INSTALLDIR", IniFileAction.createLine, "discovery", "enabled", "false"),
new IniFile("config.ini", "INSTALLDIR", IniFileAction.createLine, "info", "enabled_server", "[IP_ADRESS]"));Support for CustomActionsRef:
var project =
new Project("MyProduct",
new Dir(@"%ProgramFiles%\My Company\My Product",
new CustomActionRef ("WixFailWhenDeferred",
When.Before,
Step.InstallFinalize,
"WIXFAILWHENDEFERRED=1")
...
project.IncludeWixExtension(WixExtension.Util);Sample for Rollback customization:
var project =
new Project("MyProduct",
new Dir(@"%ProgramFiles%\My Company\My Product",
new ElevatedManagedAction(CustomActions.Install,
Return.check,
When.After,
Step.InstallFiles,
Condition.NOT_Installed,
CustomActions.Rollback)
{
RollbackArg = "Prop=Rollback"
}
...
public class CustomActions
{
[CustomAction]
public static ActionResult Rollback(Session session)
{
MessageBox.Show(session.Property("Prop"), "Rollback");
return ActionResult.Success;
}
...