diff --git a/QuikPak/Config.cs b/QuikPak/Config.cs index d079020..de6caeb 100644 --- a/QuikPak/Config.cs +++ b/QuikPak/Config.cs @@ -15,6 +15,8 @@ namespace QuikPak public int IdleTimeout { get; set; } = 0; public string ManagedPipelineMode { get; set; } = "Integrated"; public string ManagedRuntimeVersion { get; set; } = "v4.0"; + + public IEnumerable Certs { get; set; } } public class Endpoint @@ -23,4 +25,12 @@ namespace QuikPak public string DnsName { get; set; } public bool Secure { get; set; } = false; } + + public class Cert + { + public string Name { get; set; } + public string CertificatePath { get; set; } + + public string Password { get; set; } + } } \ No newline at end of file diff --git a/QuikPak/Program.cs b/QuikPak/Program.cs index 1991b9e..75f290a 100644 --- a/QuikPak/Program.cs +++ b/QuikPak/Program.cs @@ -3,6 +3,9 @@ using Newtonsoft.Json; using System; using System.Collections.Generic; using WixSharp; +using System.Linq; +using System.Xml; +using System.Xml.Linq; namespace QuikPak { @@ -69,15 +72,15 @@ namespace QuikPak } }) ) - }, + }, Version = new Version(config.Version) { }, GUID = string.IsNullOrWhiteSpace(config.Id) ? Guid.NewGuid() : new Guid(config.Id), UI = WUI.WixUI_ProgressOnly, OutFileName = config.Name, PreserveTempFiles = true, UpgradeCode = new Guid(config.UpgradeCode), + //Certificates = config.Certs.Select(a => new Certificate { PFXPassword = a.Password, CertificatePath = a.CertificatePath, Request = false, StoreName = StoreName.personal, StoreLocation = StoreLocation.localMachine, Name = a.Name}).ToArray() }; - project.Certificates = new Certificate[] { new Certificate() { PFXPassword = "password", CertificatePath = @"c:\bin\a.pfx", Request = false, StoreName = StoreName.personal, StoreLocation = StoreLocation.localMachine, Name = "cert1" } }; project.Properties.Add(new Property("REINSTALLMODE", "dmus")); project.MajorUpgrade = new MajorUpgrade() { AllowDowngrades = true, Schedule = UpgradeSchedule.afterInstallInitialize }; project.MajorUpgradeStrategy = new MajorUpgradeStrategy() @@ -91,8 +94,29 @@ namespace QuikPak }, RemoveExistingProductAfter = Step.InstallInitialize }; - Compiler.BuildWxs(project); - //Compiler.BuildMsi(project); + project.IncludeWixExtension(WixExtension.IIs); + Compiler.WixSourceGenerated += (document) => + { + var res = document.Descendants().Where(a => a.Name.ToString().Contains("site")); + Console.Write("df"); + // + //var website = document.DescendantNodes(); + //foreach(var cert in config.Certs) + //{ + // website.Parent.Add(new XElement("iis:Certificate", + // new XAttribute("Id", cert.Name), + // new XAttribute("Request", "no"), + // new XAttribute("Name", cert.Name), + // new XAttribute("PFXPassword", cert.Password), + // new XAttribute("StoreLocation", "localMachine"), + // new XAttribute("StoreName", "personal"), + // new XAttribute("CertificatePath", cert.CertificatePath) + // )); + // website.Add(new XElement("iis:CertificateRef", new XAttribute("Id", cert.Name))); + //} + + }; + Compiler.BuildMsi(project); } } }