diff --git a/src/Umbraco.Core/Manifest/ManifestWatcher.cs b/src/Umbraco.Core/Manifest/ManifestWatcher.cs new file mode 100644 index 0000000000..a81b3041d9 --- /dev/null +++ b/src/Umbraco.Core/Manifest/ManifestWatcher.cs @@ -0,0 +1,49 @@ +using System.Collections.Generic; +using System.IO; +using System.Web; +using Umbraco.Core.Logging; + +namespace Umbraco.Core.Manifest +{ + internal class ManifestWatcher : DisposableObject + { + private readonly List _fws = new List(); + + public void Start(params string[] packageFolders) + { + foreach (var packageFolder in packageFolders) + { + if (Directory.Exists(packageFolder) && File.Exists(Path.Combine(packageFolder, "package.manifest"))) + { + //NOTE: for some reason *.manifest doesn't work! + var fsw = new FileSystemWatcher(packageFolder, "*package.*") + { + IncludeSubdirectories = false, + NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite + }; + _fws.Add(fsw); + fsw.Changed += FswChanged; + fsw.EnableRaisingEvents = true; + } + } + } + + void FswChanged(object sender, FileSystemEventArgs e) + { + if (e.Name.InvariantContains("package.manifest")) + { + LogHelper.Info("manifest has changed, app pool is restarting (" + e.FullPath + ")"); + HttpRuntime.UnloadAppDomain(); + Dispose(); + } + } + + protected override void DisposeResources() + { + foreach (var fw in _fws) + { + fw.Dispose(); + } + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index d795fd9b90..1660ae19d2 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -316,6 +316,7 @@ + diff --git a/src/Umbraco.Web/UmbracoApplication.cs b/src/Umbraco.Web/UmbracoApplication.cs index 6561c6f5ab..3435659506 100644 --- a/src/Umbraco.Web/UmbracoApplication.cs +++ b/src/Umbraco.Web/UmbracoApplication.cs @@ -1,13 +1,17 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.IO; using System.Linq; using System.Text; using System.Web; using System.Web.Hosting; using System.Web.Mvc; using Umbraco.Core; +using Umbraco.Core.Configuration; +using Umbraco.Core.IO; using Umbraco.Core.Logging; +using Umbraco.Core.Manifest; using Umbraco.Web.Routing; using umbraco.businesslogic; @@ -18,7 +22,25 @@ namespace Umbraco.Web /// public class UmbracoApplication : UmbracoApplicationBase { - + private readonly ManifestWatcher _mw = new ManifestWatcher(); + + protected override void OnApplicationStarted(object sender, EventArgs e) + { + base.OnApplicationStarted(sender, e); + + if (ApplicationContext.Current.IsConfigured && GlobalSettings.DebugMode) + { + _mw.Start(Directory.GetDirectories(IOHelper.MapPath("~/App_Plugins/"))); + } + } + + protected override void OnApplicationEnd(object sender, EventArgs e) + { + base.OnApplicationEnd(sender, e); + + _mw.Dispose(); + } + protected override IBootManager GetBootManager() { return new WebBootManager(this);