Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Source/Applications/openXDA/openXDASetup/openXDASetup.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,9 @@
<Component Id="openXDAConfig" Permanent="yes">
<File Id="openXDA.exe.config" Name="$(var.openXDA.TargetFileName).config" Source="$(var.openXDA.TargetPath).config" />
</Component>
<Component Id="openXDADefaultConfig">
<File Id="openXDA.exe.config.default" Name="$(var.openXDA.TargetFileName).config.default" Source="$(var.openXDA.TargetPath).config" />
</Component>
<Component Id="DeviceDefinitionsMigrator">
<File Id="DeviceDefinitionsMigrator.exe" Name="$(var.DeviceDefinitionsMigrator.TargetFileName)" Source="$(var.DeviceDefinitionsMigrator.TargetPath)" />
</Component>
Expand Down
79 changes: 15 additions & 64 deletions Source/Tools/XDAUpgradeValidation/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
//
//******************************************************************************************************

using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Linq;
Expand All @@ -37,74 +38,24 @@ static void Main(string[] args)

static void ValidateDependentAssemblies()
{
const string runtimeSection =
@"<runtime>" +
@" <assemblyBinding xmlns=""urn:schemas-microsoft-com:asm.v1"">" +
@" <dependentAssembly>" +
@" <assemblyIdentity name=""Microsoft.Owin"" publicKeyToken=""31bf3856ad364e35"" culture=""neutral"" />" +
@" <bindingRedirect oldVersion=""0.0.0.0-2.1.0.0"" newVersion=""2.1.0.0"" />" +
@" </dependentAssembly>" +
@" <dependentAssembly>" +
@" <assemblyIdentity name=""Microsoft.Owin.Security"" publicKeyToken=""31bf3856ad364e35"" culture=""neutral"" />" +
@" <bindingRedirect oldVersion=""0.0.0.0-2.1.0.0"" newVersion=""2.1.0.0"" />" +
@" </dependentAssembly>" +
@" <dependentAssembly>" +
@" <assemblyIdentity name=""System.Net.Http.Formatting"" publicKeyToken=""31bf3856ad364e35"" culture=""neutral"" />" +
@" <bindingRedirect oldVersion=""0.0.0.0-5.2.3.0"" newVersion=""5.2.3.0"" />" +
@" </dependentAssembly>" +
@" <dependentAssembly>" +
@" <assemblyIdentity name=""System.Net.Http"" publicKeyToken=""b03f5f7f11d50a3a"" culture=""neutral"" />" +
@" <bindingRedirect oldVersion=""0.0.0.0-4.0.0.0"" newVersion=""4.0.0.0"" />" +
@" </dependentAssembly>" +
@" <dependentAssembly>" +
@" <assemblyIdentity name=""Newtonsoft.Json"" culture=""neutral"" publicKeyToken=""30ad4fe6b2a6aeed"" />" +
@" <bindingRedirect oldVersion=""0.0.0.0-6.0.0.0"" newVersion=""6.0.0.0"" />" +
@" </dependentAssembly>" +
@" <dependentAssembly>" +
@" <assemblyIdentity name=""System.Web.Optimization"" publicKeyToken=""31bf3856ad364e35"" />" +
@" <bindingRedirect oldVersion=""1.0.0.0-1.1.0.0"" newVersion=""1.1.0.0"" />" +
@" </dependentAssembly>" +
@" <dependentAssembly>" +
@" <assemblyIdentity name=""WebGrease"" publicKeyToken=""31bf3856ad364e35"" />" +
@" <bindingRedirect oldVersion=""0.0.0.0-1.6.5135.21930"" newVersion=""1.6.5135.21930"" />" +
@" </dependentAssembly>" +
@" <dependentAssembly>" +
@" <assemblyIdentity name=""System.Web.Helpers"" publicKeyToken=""31bf3856ad364e35"" />" +
@" <bindingRedirect oldVersion=""1.0.0.0-3.0.0.0"" newVersion=""3.0.0.0"" />" +
@" </dependentAssembly>" +
@" <dependentAssembly>" +
@" <assemblyIdentity name=""System.Web.Mvc"" publicKeyToken=""31bf3856ad364e35"" />" +
@" <bindingRedirect oldVersion=""1.0.0.0-5.2.3.0"" newVersion=""5.2.3.0"" />" +
@" </dependentAssembly>" +
@" <dependentAssembly>" +
@" <assemblyIdentity name=""System.Web.WebPages"" publicKeyToken=""31bf3856ad364e35"" />" +
@" <bindingRedirect oldVersion=""1.0.0.0-3.0.0.0"" newVersion=""3.0.0.0"" />" +
@" </dependentAssembly>" +
@" <dependentAssembly>" +
@" <assemblyIdentity name=""Antlr3.Runtime"" publicKeyToken=""eb42632606e9261f"" culture=""neutral"" />" +
@" <bindingRedirect oldVersion=""0.0.0.0-3.5.0.2"" newVersion=""3.5.0.2"" />" +
@" </dependentAssembly>" +
@" </assemblyBinding>" +
@"</runtime>";

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<XElement> defaultBindings = defaultDoc.Descendants(assemblyBindingSection);
Comment thread
elwills marked this conversation as resolved.

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);
}
}
}
Loading