diff --git a/src/Umbraco.Web.UI/umbraco/Install/Views/Web.config b/src/Umbraco.Web.UI/umbraco/Install/Views/Web.config index cc896163c6..d7f2ec9848 100644 --- a/src/Umbraco.Web.UI/umbraco/Install/Views/Web.config +++ b/src/Umbraco.Web.UI/umbraco/Install/Views/Web.config @@ -1,4 +1,4 @@ - + diff --git a/src/Umbraco.Web/Install/InstallHelper.cs b/src/Umbraco.Web/Install/InstallHelper.cs index c882a83cd8..59e073dc8c 100644 --- a/src/Umbraco.Web/Install/InstallHelper.cs +++ b/src/Umbraco.Web/Install/InstallHelper.cs @@ -46,6 +46,7 @@ namespace Umbraco.Web.Install new UpgradeStep(), new FilePermissionsStep(), new MajorVersion7UpgradeReport(_umbContext.Application), + new Version73FileCleanup(_umbContext.HttpContext, _umbContext.Application.ProfilingLogger.Logger), new DatabaseConfigureStep(_umbContext.Application), new DatabaseInstallStep(_umbContext.Application), new DatabaseUpgradeStep(_umbContext.Application), diff --git a/src/Umbraco.Web/Install/InstallSteps/Version73FileCleanup.cs b/src/Umbraco.Web/Install/InstallSteps/Version73FileCleanup.cs new file mode 100644 index 0000000000..f15463dc5f --- /dev/null +++ b/src/Umbraco.Web/Install/InstallSteps/Version73FileCleanup.cs @@ -0,0 +1,90 @@ +using System; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading; +using System.Web; +using Umbraco.Core.Configuration; +using Umbraco.Core.Logging; +using Umbraco.Web.Install.Models; + +namespace Umbraco.Web.Install.InstallSteps +{ + [InstallSetupStep(InstallationType.Upgrade, + "Version73FileCleanup", 2, + "Performing some housecleaning...", + PerformsAppRestart = true)] + internal class Version73FileCleanup : InstallSetupStep + { + private readonly HttpContextBase _httpContext; + private readonly ILogger _logger; + + public Version73FileCleanup(HttpContextBase httpContext, ILogger logger) + { + _httpContext = httpContext; + _logger = logger; + } + + /// + /// The step execution method + /// + /// + /// + public override InstallSetupResult Execute(object model) + { + //first cleanup all web.configs + + var root = new DirectoryInfo(_httpContext.Server.MapPath("~/")); + ProcessWebConfigs(root); + + //now remove the dll + + var bin = root.GetDirectories("bin", SearchOption.TopDirectoryOnly); + if (bin.Length == 1) + { + var dll = bin[0].GetFiles("Microsoft.Web.Mvc.FixedDisplayModes.dll", SearchOption.TopDirectoryOnly); + if (dll.Length == 1) + { + _logger.Info("Deleting non-compatible and no longer used DLL: {0}", () => dll[0].FullName); + File.Delete(dll[0].FullName); + } + } + + return null; + } + + /// + /// Determines if this step needs to execute based on the current state of the application and/or install process + /// + /// + public override bool RequiresExecution(object model) + { + return UmbracoVersion.Current == Version.Parse("7.3.0"); + } + + private void ProcessWebConfigs(DirectoryInfo dir) + { + //Do the processing of files + var found = dir.GetFiles("web.config", SearchOption.AllDirectories); + + foreach (var configFile in found) + { + var fileName = configFile.FullName; + _logger.Info("Cleaning up web.config file: {0}", () => fileName); + + var contents = File.ReadAllText(fileName); + contents = _microsoftWebHelpers.Replace(contents, string.Empty); + contents = _webPagesRazorVersion.Replace(contents, "$1=3.0.0.0"); + contents = _mvcVersion.Replace(contents, "$1=5.2.3.0"); + using (var writer = new StreamWriter(configFile.FullName, false)) + { + writer.Write(contents); + } + } + } + + private readonly Regex _microsoftWebHelpers = new Regex(@"", RegexOptions.Compiled); + private readonly Regex _webPagesRazorVersion = new Regex(@"(System\.Web\.WebPages\.Razor,\s*?Version)(=2\.0\.0\.0)", RegexOptions.Compiled); + private readonly Regex _mvcVersion = new Regex(@"(System\.Web\.Mvc,\s*?Version)(=4\.0\.0\.0)", RegexOptions.Compiled); + } +} \ No newline at end of file diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 8c243f461e..3fbdb375a3 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -300,6 +300,7 @@ +