From 73d541ad80f0b1999d6fe604bed1b48c139a7e2d Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Tue, 11 Dec 2012 16:23:15 -0100 Subject: [PATCH] Preserve existing whitespace in web.config file to make upgrades a LITTLE easier --- src/Umbraco.Core/Configuration/GlobalSettings.cs | 5 +++-- src/Umbraco.Core/DatabaseContext.cs | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Core/Configuration/GlobalSettings.cs b/src/Umbraco.Core/Configuration/GlobalSettings.cs index 5b9f24551d..d46eb76a2a 100644 --- a/src/Umbraco.Core/Configuration/GlobalSettings.cs +++ b/src/Umbraco.Core/Configuration/GlobalSettings.cs @@ -201,7 +201,8 @@ namespace Umbraco.Core.Configuration } string fileName = String.Concat(vDir, "web.config"); - var xml = XDocument.Load(fileName); + var xml = XDocument.Load(fileName, LoadOptions.PreserveWhitespace); + var appSettings = xml.Root.Descendants("appSettings").Single(); // Update appSetting if it exists, or else create a new appSetting for the given key and value @@ -211,7 +212,7 @@ namespace Umbraco.Core.Configuration else setting.Attribute("value").Value = value; - xml.Save(fileName); + xml.Save(fileName, SaveOptions.DisableFormatting); ConfigurationManager.RefreshSection("appSettings"); } diff --git a/src/Umbraco.Core/DatabaseContext.cs b/src/Umbraco.Core/DatabaseContext.cs index 655801dddf..f17c1b0ee6 100644 --- a/src/Umbraco.Core/DatabaseContext.cs +++ b/src/Umbraco.Core/DatabaseContext.cs @@ -215,7 +215,7 @@ namespace Umbraco.Core } string fileName = String.Concat(vDir, "web.config"); - var xml = XDocument.Load(fileName); + var xml = XDocument.Load(fileName, LoadOptions.PreserveWhitespace); var connectionstrings = xml.Root.Descendants("connectionStrings").Single(); // Update connectionString if it exists, or else create a new appSetting for the given key and value @@ -230,7 +230,7 @@ namespace Umbraco.Core setting.Attribute("connectionString").Value = connectionString; } - xml.Save(fileName); + xml.Save(fileName, SaveOptions.DisableFormatting); LogHelper.Info("Configured new ConnectionString: " + connectionString); }