Moves appSettings to external file and updates the code that modifies the app settings.

This commit is contained in:
Shannon
2013-10-04 10:34:00 +10:00
parent ff3aebd4b1
commit c6229f131a
9 changed files with 59 additions and 93 deletions

View File

@@ -265,10 +265,10 @@ namespace Umbraco.Core.Configuration
/// <param name="value">Value of the setting to be saved.</param>
internal static void SaveSetting(string key, string value)
{
var fileName = GetFullWebConfigFileName();
var fileName = IOHelper.MapPath(string.Format("{0}/appSettings.config", SystemDirectories.Config));
var xml = XDocument.Load(fileName, LoadOptions.PreserveWhitespace);
var appSettings = xml.Root.Descendants("appSettings").Single();
var appSettings = xml.Root.DescendantsAndSelf("appSettings").Single();
// Update appSetting if it exists, or else create a new appSetting for the given key and value
var setting = appSettings.Descendants("add").FirstOrDefault(s => s.Attribute("key").Value == key);
@@ -287,10 +287,10 @@ namespace Umbraco.Core.Configuration
/// <param name="key">Key of the setting to be removed.</param>
internal static void RemoveSetting(string key)
{
var fileName = GetFullWebConfigFileName();
var fileName = IOHelper.MapPath(string.Format("{0}/appSettings.config", SystemDirectories.Config));
var xml = XDocument.Load(fileName, LoadOptions.PreserveWhitespace);
var appSettings = xml.Root.Descendants("appSettings").Single();
var appSettings = xml.Root.DescendantsAndSelf("appSettings").Single();
var setting = appSettings.Descendants("add").FirstOrDefault(s => s.Attribute("key").Value == key);
if (setting != null)
@@ -301,21 +301,6 @@ namespace Umbraco.Core.Configuration
}
}
private static string GetFullWebConfigFileName()
{
var webConfig = new WebConfigurationFileMap();
var vDir = FullpathToRoot;
foreach (VirtualDirectoryMapping v in webConfig.VirtualDirectories)
{
if (v.IsAppRoot)
vDir = v.PhysicalDirectory;
}
var fileName = System.IO.Path.Combine(vDir, "web.config");
return fileName;
}
/// <summary>
/// Gets the full path to root.
/// </summary>

View File

@@ -628,6 +628,10 @@
<None Include="Config\BaseRestExtensions.Release.config">
<DependentUpon>BaseRestExtensions.config</DependentUpon>
</None>
<Content Include="Config\appSettings.config" />
<Content Include="Config\appSettings.Release.config">
<DependentUpon>appSettings.config</DependentUpon>
</Content>
<None Include="Config\log4net.Release.config">
<DependentUpon>log4net.config</DependentUpon>
</None>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8" ?>
<appSettings>
<!--
Umbraco web.config configuration documentation can be found here:
http://our.umbraco.org/documentation/using-umbraco/config-files/#webconfig
-->
<add key="umbracoConfigurationStatus" value="" />
<add key="umbracoReservedUrls" value="~/config/splashes/booting.aspx,~/install/default.aspx,~/config/splashes/noNodes.aspx,~/VSEnterpriseHelper.axd" />
<add key="umbracoReservedPaths" value="~/umbraco,~/install/" />
<add key="umbracoPath" value="~/umbraco" />
<add key="umbracoHideTopLevelNodeFromPath" value="true" />
<add key="umbracoUseDirectoryUrls" value="true" />
<add key="umbracoTimeOutInMinutes" value="20" />
<add key="umbracoDefaultUILanguage" value="en" />
<add key="umbracoUseSSL" value="false" />
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
<add key="webpages:Enabled" value="false"/>
<add key="enableSimpleMembership" value="false"/>
<add key="autoFormsAuthentication" value="false"/>
<add key="log4net.Config" value="config\log4net.config" />
</appSettings>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<appSettings>
<!--
Umbraco web.config configuration documentation can be found here:
http://our.umbraco.org/documentation/using-umbraco/config-files/#webconfig
-->
<add key="umbracoConfigurationStatus" value="7.0.0" />
<add key="umbracoReservedUrls" value="~/config/splashes/booting.aspx,~/install/default.aspx,~/config/splashes/noNodes.aspx,~/VSEnterpriseHelper.axd" />
<add key="umbracoReservedPaths" value="~/umbraco,~/install/" />
<add key="umbracoPath" value="~/umbraco" />
<add key="umbracoHideTopLevelNodeFromPath" value="true" />
<add key="umbracoUseDirectoryUrls" value="true" />
<add key="umbracoTimeOutInMinutes" value="20" />
<add key="umbracoDefaultUILanguage" value="en" />
<add key="umbracoUseSSL" value="false" />
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
<add key="webpages:Enabled" value="false" />
<add key="enableSimpleMembership" value="false" />
<add key="autoFormsAuthentication" value="false" />
<add key="log4net.Config" value="config\log4net.config" />
</appSettings>

View File

@@ -46,11 +46,8 @@
<dashBoard configSource="config\Dashboard.config"/>
</umbracoConfiguration>
<appSettings>
<add key="umbracoDbDSN" xdt:Transform="Remove" xdt:Locator="Match(key)" />
<add key="ValidationSettings:UnobtrusiveValidationMode" xdt:Transform="RemoveAll" xdt:Locator="Match(key)" />
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" xdt:Locator="Match(key)" xdt:Transform="Insert" />
</appSettings>
<appSettings xdt:Transform="Remove" />
<appSettings configSource="config\appSettings.config" xdt:Transform="InsertAfter(/configuration/umbracoConfiguration)" />
<system.web>
<xhtmlConformance xdt:Transform="Remove"/>

View File

@@ -9,14 +9,6 @@
Umbraco RELEASE version - The version that everybody will download and use
-->
<appSettings>
<add xdt:Transform="Replace" xdt:Locator="Match(key)" key="umbracoDbDSN"
value=""/>
<add xdt:Transform="Replace" xdt:Locator="Match(key)" key="umbracoConfigurationStatus"
value=""/>
</appSettings>
<system.web>
<trust xdt:Transform="Remove"/>
<globalization xdt:Transform="Remove"/>

View File

@@ -29,28 +29,7 @@
<ExamineLuceneIndexSets configSource="config\ExamineIndex.config" />
<log4net configSource="config\log4net.config" />
<appSettings>
<!--
Umbraco web.config configuration documentation can be found here:
http://our.umbraco.org/documentation/using-umbraco/config-files/#webconfig
-->
<add key="umbracoConfigurationStatus" value="" />
<add key="umbracoReservedUrls" value="~/config/splashes/booting.aspx,~/install/default.aspx,~/config/splashes/noNodes.aspx,~/VSEnterpriseHelper.axd" />
<add key="umbracoReservedPaths" value="~/umbraco,~/install/" />
<add key="umbracoPath" value="~/umbraco" />
<add key="umbracoHideTopLevelNodeFromPath" value="true" />
<add key="umbracoUseDirectoryUrls" value="true" />
<add key="umbracoTimeOutInMinutes" value="20" />
<add key="umbracoDefaultUILanguage" value="en" />
<add key="umbracoUseSSL" value="false" />
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
<add key="webpages:Enabled" value="false"/>
<add key="enableSimpleMembership" value="false"/>
<add key="autoFormsAuthentication" value="false"/>
<add key="log4net.Config" value="config\log4net.config" />
</appSettings>
<appSettings configSource="config\appSettings.config" />
<system.data>
<DbProviderFactories>

View File

@@ -1,36 +0,0 @@
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false"/>
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false"/>
</sectionGroup>
</configSections>
<appSettings>
<add key="webPages:Enabled" value="false"/>
<add key="enableSimpleMembership" value="false"/>
<add key="autoFormsAuthentication" value="false"/>
</appSettings>
<system.web.webPages.razor>
<host factoryType="umbraco.MacroEngines.RazorUmbracoFactory, umbraco.MacroEngines"/>
<pages pageBaseType="umbraco.MacroEngines.DynamicNodeContext">
<namespaces>
<add namespace="Microsoft.Web.Helpers"/>
</namespaces>
</pages>
</system.web.webPages.razor>
<system.web>
<compilation>
<buildProviders>
<add extension=".cshtml" type="umbraco.MacroEngines.RazorBuildProvider, umbraco.MacroEngines"/>
<add extension=".vbhtml" type="umbraco.MacroEngines.RazorBuildProvider, umbraco.MacroEngines"/>
<add extension=".razor" type="umbraco.MacroEngines.RazorBuildProvider, umbraco.MacroEngines"/>
</buildProviders>
</compilation>
</system.web>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>

View File

@@ -217,9 +217,6 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="App.Config">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />