From c9deed06b1311c08aa79efba90c8c8880f92d4d6 Mon Sep 17 00:00:00 2001 From: Oleg Shilo Date: Wed, 22 Jan 2025 23:22:44 +1100 Subject: [PATCH] #1732: If any of Extensions.GenericEntities, MIMETypes, or Verbs are set, all must be set --- .../Wix# Samples/ComServer/setup.cs | 19 ++++++++++-- Source/src/WixSharp/ComRegistration.cs | 29 +++++++++---------- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/Source/src/WixSharp.Samples/Wix# Samples/ComServer/setup.cs b/Source/src/WixSharp.Samples/Wix# Samples/ComServer/setup.cs index 2d8886c3..f0d5f3b4 100644 --- a/Source/src/WixSharp.Samples/Wix# Samples/ComServer/setup.cs +++ b/Source/src/WixSharp.Samples/Wix# Samples/ComServer/setup.cs @@ -2,6 +2,7 @@ //css_ref Wix_bin\WixToolset.Dtf.WindowsInstaller.dll; //css_ref System.Core.dll; using System; +using System.Diagnostics; using WixSharp; class Script @@ -25,7 +26,7 @@ static public void Build() var project = new Project("MyProduct", new Dir(@"%ProgramFiles%\My Company\My Product", - new File(@"Files\Bin\MyApp.exe", + new File(new Id("MyApp.exe"), @"Files\Bin\MyApp.exe", new TypeLib { Id = new Guid("6f330b47-2577-43ad-9095-1861ba25889b"), @@ -50,6 +51,21 @@ static public void Build() { Id = "prog.id", Description="some description" + ,Extensions = new[] + { + new Extension + { + ContentType = "text/plain", + Verbs = new [] + { + new Verb + { + TargetFile = "MyApp.exe", + } + }, + + } + } } } } @@ -58,7 +74,6 @@ static public void Build() project.GUID = new Guid("6f330b47-2577-43ad-9095-1861ba25889b"); // project.PreserveTempFiles = true; - project.BuildMsi(); } diff --git a/Source/src/WixSharp/ComRegistration.cs b/Source/src/WixSharp/ComRegistration.cs index bbbbd164..aeb87520 100644 --- a/Source/src/WixSharp/ComRegistration.cs +++ b/Source/src/WixSharp/ComRegistration.cs @@ -576,17 +576,17 @@ public Extension() /// Extensibility point in the WiX XML Schema. /// Schema extensions can register additional attributes at this point in the schema. /// - public IGenericEntity[] GenericEntities; + public IGenericEntity[] GenericEntities = new IGenericEntity[0]; /// /// MIME content-types for an . /// - public MimeType[] MIMETypes; + public MimeType[] MIMETypes = new MimeType[0]; /// /// Verb definitions for an . /// - public Verb[] Verbs; + public Verb[] Verbs = new Verb[0]; /// /// Adds itself as an XML content into the WiX source being generated from the . @@ -606,20 +606,17 @@ public void Process(ProcessingContext context) if (!Advertise.HasValue) Advertise = false; - if (GenericEntities?.Length > 0 || MIMETypes?.Length > 0 || Verbs?.Length > 0) + var extensionContext = new ProcessingContext { - var extensionContext = new ProcessingContext - { - Project = context.Project, - Parent = this, - FeatureComponents = context.FeatureComponents, - XParent = element - }; - - _ = GenericEntities.ForEach(e => e.Process(extensionContext)); - _ = MIMETypes.ForEach(t => t.Process(extensionContext)); - _ = Verbs.ForEach(v => v.Process(extensionContext)); - } + Project = context.Project, + Parent = this, + FeatureComponents = context.FeatureComponents, + XParent = element + }; + + GenericEntities.ForEach(e => e.Process(extensionContext)); + MIMETypes.ForEach(t => t.Process(extensionContext)); + Verbs.ForEach(v => v.Process(extensionContext)); context.XParent.Add(element); }