#U4-1246 Increase the version number in ClientDependency.config after install

This commit is contained in:
Sebastiaan Janssen
2012-12-12 09:07:06 -01:00
parent 5f93e20fab
commit 849a9892c5
3 changed files with 55 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
using System;
using System.Linq;
using System.Xml.Linq;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
namespace Umbraco.Core.Configuration
{
internal class ClientDependencyConfiguration
{
private readonly string _fileName;
public ClientDependencyConfiguration()
{
_fileName = IOHelper.MapPath(string.Format("{0}/ClientDependency.config", SystemDirectories.Config));
}
/// <summary>
/// Increases the version number in ClientDependency.config by 1
/// </summary>
internal bool IncreaseVersionNumber()
{
try
{
var clientDependencyConfigXml = XDocument.Load(_fileName, LoadOptions.PreserveWhitespace);
if (clientDependencyConfigXml.Root != null)
{
var versionAttribute = clientDependencyConfigXml.Root.Attribute("version");
int oldVersion;
int.TryParse(versionAttribute.Value, out oldVersion);
var newVersion = oldVersion + 1;
versionAttribute.SetValue(newVersion);
clientDependencyConfigXml.Save(_fileName, SaveOptions.DisableFormatting);
LogHelper.Info<ClientDependencyConfiguration>(string.Format("Updated version number from {0} to {1}", oldVersion, newVersion));
return true;
}
}
catch (Exception ex)
{
LogHelper.Error<ClientDependencyConfiguration>("Couldn't update ClientDependency version number", ex);
}
return false;
}
}
}

View File

@@ -105,6 +105,7 @@
<Compile Include="CodeAnnotations\UmbracoWillObsoleteAttribute.cs" />
<Compile Include="CodeAnnotations\UmbracoExperimentalFeatureAttribute.cs" />
<Compile Include="CodeAnnotations\UmbracoProposedPublicAttribute.cs" />
<Compile Include="Configuration\ClientDependencyConfiguration.cs" />
<Compile Include="Configuration\FileSystemProviderElement.cs" />
<Compile Include="Configuration\FileSystemProviderElementCollection.cs" />
<Compile Include="Configuration\FileSystemProvidersSection.cs" />

View File

@@ -33,6 +33,10 @@ namespace umbraco.presentation.install.steps
//errorLiteral.Text = ex.ToString();
}
// Update ClientDependency version
var clientDependencyConfig = new ClientDependencyConfiguration();
var clientDependencyUpdated = clientDependencyConfig.IncreaseVersionNumber();
if (!cms.businesslogic.skinning.Skinning.IsStarterKitInstalled())
customizeSite.Visible = false;