From c9ec41d308e9d830b476b587bf8d77ef4738de1a Mon Sep 17 00:00:00 2001 From: Oleg Shilo Date: Sat, 29 Jun 2024 14:25:14 +1000 Subject: [PATCH] Wix4: Release v2.2.0 - The whole round trip implementation for the elevated events (#1565, #1567). Not integrated to the API yet - added `restart elevated` routine for custom BA sample - Issue #1554: Add custom Wizard-like Installer to Bundle / Burn Installer - Implemented `MsiExePackage`. Triggered by #1554 Dedicates sample `WixBootstrapper_MsiEmbeddedUI` shows how to use it ```C# var bootstrapper = new Bundle("Managed Product Bundle", new MsiExePackage(msi) { Name = "ManagedProduct", }); ``` - Issue #1557: Error when specifying Package Platform as ARM64 - WiX4: added `WixProject.WixBuildCommandGenerated` even. Triggered by #1557 - Added `CommonTasks.MapAsDeferredProperty` extension method: ```C# project.MapAsDeferredProperty("MYPROPERTY"); // instead of project.DefaultDeferredProperties += ",MYPROPERTY"; ``` - Added `string.CompleSelfHostedMsi` extension for building self executable msi files: ```C# msi.CompleSelfHostedMsi(msi + ".exe"); ``` - added calling `dotnet tool restore` when using wix as a local tool. Triggered by #1546 --- .../WixSharp.Core/WixSharp.Core.csproj | 14 +++++++++--- .../WixSharp.Msi.Core.csproj | 2 +- .../Wix# Samples/Install Files/setup.cs | 13 ++++++----- .../InstallEventElevation/setup.cs | 22 ++++++++++++++----- .../CustomUI.WPF/CustomWpfDialog.xaml.cs | 11 ++++++++-- .../CustomUI.WPF/CustomWpfDialogRaw.xaml.cs | 9 ++++++-- .../Managed Setup/CustomUI.WPF/setup.cs | 4 ++-- .../Wix# Samples/Shortcuts/setup.cs | 11 ++++++++-- .../ManagedUI/Forms/WelcomeDialog.cs | 2 ++ .../ManagedProject/ManagedProjectActions.cs | 9 ++++---- .../Properties/AssemblyInfo.version.cs | 4 ++-- ...chedProperies.cs => AttachedProperties.cs} | 2 +- Source/src/WixSharp/WixSharp.csproj | 2 +- 13 files changed, 74 insertions(+), 31 deletions(-) rename Source/src/WixSharp/Utilities/{AttachedProperies.cs => AttachedProperties.cs} (98%) diff --git a/Source/src/NET-Core/WixSharp.Core/WixSharp.Core.csproj b/Source/src/NET-Core/WixSharp.Core/WixSharp.Core.csproj index 0f91fbe6..fd83f7a5 100644 --- a/Source/src/NET-Core/WixSharp.Core/WixSharp.Core.csproj +++ b/Source/src/NET-Core/WixSharp.Core/WixSharp.Core.csproj @@ -13,12 +13,12 @@ True True snupkg - 2.1.4 - 2.1.5 + 2.2.0 + 2.2.0 - 2.1.9 + 2.2.0 WixSharp (.NET Core) .NET Core edition of WixSharp package Oleg Shilo @@ -200,6 +200,14 @@ + + + + + + + + diff --git a/Source/src/NET-Core/WixSharp.Msi.Core/WixSharp.Msi.Core.csproj b/Source/src/NET-Core/WixSharp.Msi.Core/WixSharp.Msi.Core.csproj index 9038b80e..21d94a10 100644 --- a/Source/src/NET-Core/WixSharp.Msi.Core/WixSharp.Msi.Core.csproj +++ b/Source/src/NET-Core/WixSharp.Msi.Core/WixSharp.Msi.Core.csproj @@ -24,7 +24,7 @@ - 2.1.9 + 2.2.0 WixSharp (.NET Core) .NET Core edition of WixSharp.Msi package Oleg Shilo diff --git a/Source/src/WixSharp.Samples/Wix# Samples/Install Files/setup.cs b/Source/src/WixSharp.Samples/Wix# Samples/Install Files/setup.cs index 8ee5b3e0..f120c5b7 100644 --- a/Source/src/WixSharp.Samples/Wix# Samples/Install Files/setup.cs +++ b/Source/src/WixSharp.Samples/Wix# Samples/Install Files/setup.cs @@ -22,10 +22,12 @@ static public void Main() var project = new ManagedProject("MyProduct", - new Dir(@"AppDataFolder\My ICompany\My Product", - // new Dir(new Id("MY_INSTALLDIR"), @"%ProgramFiles%\My ICompany\My Product", + // new Dir(@"AppDataFolder\My ICompany\My Product", + new Dir(new Id("MY_INSTALLDIR"), @"%ProgramFiles%\My ICompany\My Product", f = new File("MyApp_file".ToId(), - @"Files\Bin\MyApp.exe", + @"C:\sourceFiles\MyApp.exe", + // @"Files\Bin\MyApp.exe", + // @"D:\dev\wixsharp-wix4\Source\src\WixSharp.Samples\Wix# Samples\Install Files\Files\Bin\MyApp.exe", new FileAssociation("cstm", "application/custom", "open", "\"%1\"") { Advertise = true, @@ -35,7 +37,8 @@ static public void Main() TargetFileName = "app.exe" }, new Dir(@"Docs\Manual", - new File(@"Files\Docs\Manual.txt") + // new File(@"Files\Docs\Manual.txt") + new File(@"D:\dev\wixsharp-wix4\Source\src\WixSharp.Samples\Wix# Samples\Install Files\Files\Docs\Manual.txt") { NeverOverwrite = true })), @@ -44,7 +47,7 @@ static public void Main() project.SetVersionFrom("MyApp_file"); project.GUID = new Guid("6f330b47-2577-43ad-9095-1861ba25889b"); - + Compiler.EmitRelativePaths = false; // possible UIs project.ManagedUI = ManagedUI.Default; // project.ManagedUI = ManagedUI.DefaultWpf; diff --git a/Source/src/WixSharp.Samples/Wix# Samples/InstallEventElevation/setup.cs b/Source/src/WixSharp.Samples/Wix# Samples/InstallEventElevation/setup.cs index 710f4a34..fde62833 100644 --- a/Source/src/WixSharp.Samples/Wix# Samples/InstallEventElevation/setup.cs +++ b/Source/src/WixSharp.Samples/Wix# Samples/InstallEventElevation/setup.cs @@ -13,6 +13,7 @@ using WixSharp; using WixSharp.CommonTasks; using WixSharp.UI; +using WixToolset.Dtf.WindowsInstaller; static class Script { @@ -27,20 +28,29 @@ static public void Main() project.UI = WUI.WixUI_ProgressOnly; - // project.Scope = InstallScope.perMachine; - project.Scope = InstallScope.perUser; - project.BeforeInstall += Project_BeforeInstall; - project.AfterInstall += Project_AfterInstall; + project.AfterInstall += Project_AfterInstall; // is already elevated (deferred by default) + + bool installPerUser = false; + if (installPerUser) + { + project.Scope = InstallScope.perUser; + project.BeforeInstallEventExecution = EventExecution.ExternalElevatedProcess; + } + else + { + project.Scope = InstallScope.perMachine; + project.BeforeInstallEventExecution = EventExecution.MsiSessionScopeDeferred; + // you can use ExternalElevatedProcess too + } - project.BeforeInstallEventExecution = EventExecution.ExternalElevatedProcess; project.BuildMsi(); } private static void Project_BeforeInstall(SetupEventArgs e) { MessageBox.Show(e.ToString(), "Project_BeforeInstall"); - // e.Result = WixToolset.Dtf.WindowsInstaller.ActionResult.UserExit; + e.Result = ActionResult.UserExit; // canceling the install here } private static void Project_AfterInstall(SetupEventArgs e) diff --git a/Source/src/WixSharp.Samples/Wix# Samples/Managed Setup/CustomUI.WPF/CustomWpfDialog.xaml.cs b/Source/src/WixSharp.Samples/Wix# Samples/Managed Setup/CustomUI.WPF/CustomWpfDialog.xaml.cs index 723afed2..bf21ec27 100644 --- a/Source/src/WixSharp.Samples/Wix# Samples/Managed Setup/CustomUI.WPF/CustomWpfDialog.xaml.cs +++ b/Source/src/WixSharp.Samples/Wix# Samples/Managed Setup/CustomUI.WPF/CustomWpfDialog.xaml.cs @@ -1,6 +1,7 @@ -using Caliburn.Micro; -using System; +using System; +using System.Windows; using System.Windows.Media.Imaging; +using Caliburn.Micro; using WixSharp; using WixSharp.UI.Forms; using WixSharp.UI.WPF; @@ -16,6 +17,12 @@ public CustomDialogView() public void Init() { + var topWindow = this.ManagedFormHost.Parent as System.Windows.Forms.Form; + topWindow.FormClosing += (sender, e) => + { + MessageBox.Show("Closing..."); + }; + ViewModelBinder.Bind(new CustomDialogModel { Host = ManagedFormHost }, this, null); } } diff --git a/Source/src/WixSharp.Samples/Wix# Samples/Managed Setup/CustomUI.WPF/CustomWpfDialogRaw.xaml.cs b/Source/src/WixSharp.Samples/Wix# Samples/Managed Setup/CustomUI.WPF/CustomWpfDialogRaw.xaml.cs index cc5813f6..cc88ffcf 100644 --- a/Source/src/WixSharp.Samples/Wix# Samples/Managed Setup/CustomUI.WPF/CustomWpfDialogRaw.xaml.cs +++ b/Source/src/WixSharp.Samples/Wix# Samples/Managed Setup/CustomUI.WPF/CustomWpfDialogRaw.xaml.cs @@ -1,6 +1,7 @@ -using Caliburn.Micro; -using System; +using System; +using System.Windows; using System.Windows.Media.Imaging; +using Caliburn.Micro; using WixSharp; using WixSharp.UI.Forms; using WixSharp.UI.WPF; @@ -20,6 +21,10 @@ public CustomDialogRawView() public void Init() { + this.ManagedFormHost.FormClosing += (sender, e) => + { + MessageBox.Show("Closing1"); + }; Banner.Source = this.ManagedFormHost?.Runtime.Session.GetResourceBitmap("WixUI_Bmp_Banner").ToImageSource(); } diff --git a/Source/src/WixSharp.Samples/Wix# Samples/Managed Setup/CustomUI.WPF/setup.cs b/Source/src/WixSharp.Samples/Wix# Samples/Managed Setup/CustomUI.WPF/setup.cs index 9958d578..932c6254 100644 --- a/Source/src/WixSharp.Samples/Wix# Samples/Managed Setup/CustomUI.WPF/setup.cs +++ b/Source/src/WixSharp.Samples/Wix# Samples/Managed Setup/CustomUI.WPF/setup.cs @@ -16,10 +16,10 @@ static public void Main(string[] args) project.GUID = new Guid("6f330b47-2577-43ad-9095-1861ba25889b"); project.ManagedUI = new ManagedUI(); project.ManagedUI.InstallDialogs.Add() // stock WinForm dialog - .Add() // stock WinForm dialog + .Add() // custom WPF dialog (with Claiburn.Micro as MVVM) .Add>() // custom WPF dialog (minimalistic); + .Add() // stock WinForm dialog .Add() // custom WPF dialog - .Add() // custom WPF dialog (with Claiburn.Micro as MVVM) .Add() // stock WinForm dialog .Add(); // stock WinForm dialog diff --git a/Source/src/WixSharp.Samples/Wix# Samples/Shortcuts/setup.cs b/Source/src/WixSharp.Samples/Wix# Samples/Shortcuts/setup.cs index 68aaef8b..ef3a4e95 100644 --- a/Source/src/WixSharp.Samples/Wix# Samples/Shortcuts/setup.cs +++ b/Source/src/WixSharp.Samples/Wix# Samples/Shortcuts/setup.cs @@ -25,11 +25,18 @@ static public void Main() Target = "https://github.com/oleg-shilo/wixsharp" }, new Dir("Samples", - new File(@"AppFiles\MyApp.cs")), + new File(@"AppFiles\MyApp.cs", + new FileShortcut("MyApp", @"%StartMenuFolder%") + { + IconFile = @"AppFiles\Icon.ico", + WorkingDirectory = "Samples", + Arguments = "777", + Description = "My Application" + })), new File(@"AppFiles\MyApp.exe", new FileShortcut("MyApp", "INSTALLDIR"), //INSTALLDIR is the ID of "%ProgramFiles%\My Company\My Product" - new FileShortcut("MyApp", @"%Desktop%") + new FileShortcut("MyApp", @"%StartMenuFolder%") { IconFile = @"AppFiles\Icon.ico", WorkingDirectory = "Samples", diff --git a/Source/src/WixSharp.UI/ManagedUI/Forms/WelcomeDialog.cs b/Source/src/WixSharp.UI/ManagedUI/Forms/WelcomeDialog.cs index 149f33f6..29e53565 100644 --- a/Source/src/WixSharp.UI/ManagedUI/Forms/WelcomeDialog.cs +++ b/Source/src/WixSharp.UI/ManagedUI/Forms/WelcomeDialog.cs @@ -1,4 +1,6 @@ using System; +using System.Diagnostics; +using System.Windows.Forms; namespace WixSharp.UI.Forms { diff --git a/Source/src/WixSharp/ManagedProject/ManagedProjectActions.cs b/Source/src/WixSharp/ManagedProject/ManagedProjectActions.cs index 884ed2ee..bbe94056 100644 --- a/Source/src/WixSharp/ManagedProject/ManagedProjectActions.cs +++ b/Source/src/WixSharp/ManagedProject/ManagedProjectActions.cs @@ -61,10 +61,11 @@ public static ActionResult WixSharp_Load_Action(Session session) public static ActionResult WixSharp_BeforeInstall_Action(Session session) { // Debugger.Launch(); - session["ADDFEATURES"] = session.Features - .Where(x => x.RequestState != InstallState.Absent) - .Select(x => x.Name) - .JoinBy(","); + if (session.IsActive()) + session["ADDFEATURES"] = session.Features + .Where(x => x.RequestState != InstallState.Absent) + .Select(x => x.Name) + .JoinBy(","); return ManagedProject.InvokeClientHandlers(session, "BeforeInstall"); } diff --git a/Source/src/WixSharp/Properties/AssemblyInfo.version.cs b/Source/src/WixSharp/Properties/AssemblyInfo.version.cs index 8ab9d42b..172cf0e8 100644 --- a/Source/src/WixSharp/Properties/AssemblyInfo.version.cs +++ b/Source/src/WixSharp/Properties/AssemblyInfo.version.cs @@ -7,5 +7,5 @@ // Build Number // Revision // -[assembly: AssemblyVersion("2.1.9.0")] -[assembly: AssemblyFileVersion("2.1.9.0")] \ No newline at end of file +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] \ No newline at end of file diff --git a/Source/src/WixSharp/Utilities/AttachedProperies.cs b/Source/src/WixSharp/Utilities/AttachedProperties.cs similarity index 98% rename from Source/src/WixSharp/Utilities/AttachedProperies.cs rename to Source/src/WixSharp/Utilities/AttachedProperties.cs index bd5451b4..c58c6465 100644 --- a/Source/src/WixSharp/Utilities/AttachedProperies.cs +++ b/Source/src/WixSharp/Utilities/AttachedProperties.cs @@ -9,7 +9,7 @@ namespace WixSharp /// This class allows attaching arbitrary data to any object. This behavior resembles /// AttachedProperty in WPF. /// - public static class AttachedProperies + public static class AttachedProperties { /// /// The object cache. Contains object that have values attached. diff --git a/Source/src/WixSharp/WixSharp.csproj b/Source/src/WixSharp/WixSharp.csproj index fb9ac3ff..afa48abf 100644 --- a/Source/src/WixSharp/WixSharp.csproj +++ b/Source/src/WixSharp/WixSharp.csproj @@ -113,7 +113,7 @@ - +