Fix Razor views re-compilation

When modules are switched from dynamically compiled (.csproj) to precompiled
(.dll), Razor views were sometimes not recompiled because the list of virtual
path dependencies didn't contain any path that would change during the switch.
The fix is to include "~/App_Data/Dependencies/Dependencies.xml" as a virtual
path dependency, as this file changes when module configuration changes.

Work Items: 16833

--HG--
branch : dev
This commit is contained in:
Renaud Paquay
2010-11-21 19:40:51 -08:00
parent ebc99010e4
commit 4aea24f3d5
4 changed files with 9 additions and 2 deletions

View File

@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using Orchard.Caching;
namespace Orchard.FileSystems.AppData {

View File

@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using Orchard.Caching;
using Orchard.Data;
using Orchard.FileSystems.AppData;
using Orchard.Localization;
@@ -56,6 +55,10 @@ namespace Orchard.FileSystems.Dependencies {
}
}
public IEnumerable<string> GetViewCompilationDependencies() {
yield return _appDataFolder.GetVirtualPath(this.PersistencePath);
}
private IEnumerable<DependencyDescriptor> ReadDependencies(string persistancePath) {
Func<string, XName> ns = (name => XName.Get(name));
Func<XElement, string, string> elem = (e, name) => e.Element(ns(name)).Value;

View File

@@ -23,5 +23,6 @@ namespace Orchard.FileSystems.Dependencies {
DependencyDescriptor GetDescriptor(string moduleName);
IEnumerable<DependencyDescriptor> LoadDescriptors();
void StoreDescriptors(IEnumerable<DependencyDescriptor> dependencyDescriptors);
IEnumerable<string> GetViewCompilationDependencies();
}
}

View File

@@ -55,6 +55,10 @@ namespace Orchard.Mvc.ViewEngines.Razor {
provider.AddVirtualPathDependency(virtualDependency);
}
}
foreach (var virtualDependency in _dependenciesFolder.GetViewCompilationDependencies()) {
provider.AddVirtualPathDependency(virtualDependency);
}
}
public void CodeGenerationCompleted(RazorBuildProvider provider, CodeGenerationCompleteEventArgs e) {