From c56a0314c52e1fa32cef3fd256f7356d4dbde4f4 Mon Sep 17 00:00:00 2001 From: StephenCWills Date: Tue, 22 Sep 2026 13:42:16 -0400 Subject: [PATCH] Tweak XDAUpgradeValidation to use assembly bindings generated at build time --- .../openXDA/openXDASetup/openXDASetup.wxs | 3 + Source/Tools/XDAUpgradeValidation/Program.cs | 79 ++++--------------- 2 files changed, 18 insertions(+), 64 deletions(-) diff --git a/Source/Applications/openXDA/openXDASetup/openXDASetup.wxs b/Source/Applications/openXDA/openXDASetup/openXDASetup.wxs index 00db239baa..3fefdc4d51 100755 --- a/Source/Applications/openXDA/openXDASetup/openXDASetup.wxs +++ b/Source/Applications/openXDA/openXDASetup/openXDASetup.wxs @@ -445,6 +445,9 @@ + + + diff --git a/Source/Tools/XDAUpgradeValidation/Program.cs b/Source/Tools/XDAUpgradeValidation/Program.cs index 1c5182ff90..308a161833 100644 --- a/Source/Tools/XDAUpgradeValidation/Program.cs +++ b/Source/Tools/XDAUpgradeValidation/Program.cs @@ -21,6 +21,7 @@ // //****************************************************************************************************** +using System.Collections.Generic; using System.IO; using System.Linq; using System.Xml.Linq; @@ -37,74 +38,24 @@ static void Main(string[] args) static void ValidateDependentAssemblies() { - const string runtimeSection = - @"" + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @" " + - @""; - string configFilePath = FilePath.GetAbsolutePath("openXDA.exe.config"); - XDocument doc = XDocument.Load(configFilePath); - XElement runtime = XElement.Parse(runtimeSection); + string defaultConfigFilePath = $"{configFilePath}.default"; + File.Copy(configFilePath, $"{configFilePath}.prev", true); - if (!doc.Descendants("runtime").Any()) - { - doc.Element("configuration").Add(runtime); - doc.Save(configFilePath); - return; - } + XNamespace ns = "urn:schemas-microsoft-com:asm.v1"; + XName assemblyBindingSection = ns + "assemblyBinding"; + XDocument defaultDoc = XDocument.Load(defaultConfigFilePath); + IEnumerable defaultBindings = defaultDoc.Descendants(assemblyBindingSection); + + XDocument doc = XDocument.Load(configFilePath); + XElement root = doc.Root; - XElement assemblyBinding = runtime.Elements().Single(); + if (!root.Elements("runtime").Any()) + root.Add(new XElement("runtime")); - if (!doc.Descendants(assemblyBinding.Name).Any()) - { - doc.Descendants("runtime").First().Add(assemblyBinding); - doc.Save(configFilePath); - } + root.Descendants(assemblyBindingSection).Remove(); + root.Element("runtime").Add(defaultBindings); + doc.Save(configFilePath); } } }