#17923: Modules from ~/Bin and ~/Core have higher priority

Because of the way ASP.NET BuildManager works(*), we can't enable
dynamic compilation of a module if the module is already
present in ~/bin.

(*) When invoking the compiler, BuildManager automatically adds
references to all assemblies present in ~/bin. So, if you have module
"X" in "~/bin", there is no way to enable dynamic compilation of
module "X" by compiling "X.csproj", as there will be tons of
compilation errors with equivalent types defined in multiple
assemblies.

--HG--
branch : 1.x
This commit is contained in:
Renaud Paquay
2011-06-09 12:53:33 -07:00
parent 5a4f0ed1f3
commit e4e359e5c1
4 changed files with 19 additions and 2 deletions

View File

@@ -247,7 +247,20 @@ namespace Orchard.Environment.Extensions {
} }
private IEnumerable<ExtensionProbeEntry> SortExtensionProbeEntries(IEnumerable<ExtensionProbeEntry> entries, ConcurrentDictionary<string, DateTime> virtualPathModficationDates) { private IEnumerable<ExtensionProbeEntry> SortExtensionProbeEntries(IEnumerable<ExtensionProbeEntry> entries, ConcurrentDictionary<string, DateTime> virtualPathModficationDates) {
return entries // All "entries" are for the same extension ID, so we just need to filter/sort them by priority+ modification dates.
var groupByPriority = entries
.GroupBy(entry => entry.Priority)
.OrderByDescending(g => g.Key);
// Select highest priority group with at least one item
var firstNonEmptyGroup = groupByPriority.FirstOrDefault(g => g.Count() >= 1) ?? Enumerable.Empty<ExtensionProbeEntry>();
// No need for further sorting if only 1 item found
if (firstNonEmptyGroup.Count() <= 1)
return firstNonEmptyGroup;
// Sort by last modification date/loader order
return firstNonEmptyGroup
.OrderByDescending(probe => GetVirtualPathDepedenciesModificationTimeUtc(virtualPathModficationDates, probe)) .OrderByDescending(probe => GetVirtualPathDepedenciesModificationTimeUtc(virtualPathModficationDates, probe))
.ThenBy(probe => probe.Loader.Order) .ThenBy(probe => probe.Loader.Order)
.ToList(); .ToList();

View File

@@ -32,6 +32,7 @@ namespace Orchard.Environment.Extensions.Loaders {
return new ExtensionProbeEntry { return new ExtensionProbeEntry {
Descriptor = descriptor, Descriptor = descriptor,
Loader = this, Loader = this,
Priority = 100, // Higher priority because assemblies in ~/bin always take precedence
VirtualPath = "~/Core/" + descriptor.Id, VirtualPath = "~/Core/" + descriptor.Id,
VirtualPathDependencies = Enumerable.Empty<string>(), VirtualPathDependencies = Enumerable.Empty<string>(),
}; };

View File

@@ -9,6 +9,7 @@ namespace Orchard.Environment.Extensions.Loaders {
public class ExtensionProbeEntry { public class ExtensionProbeEntry {
public ExtensionDescriptor Descriptor { get; set; } public ExtensionDescriptor Descriptor { get; set; }
public IExtensionLoader Loader { get; set; } public IExtensionLoader Loader { get; set; }
public int Priority { get; set; }
public string VirtualPath { get; set; } public string VirtualPath { get; set; }
public IEnumerable<string> VirtualPathDependencies { get; set; } public IEnumerable<string> VirtualPathDependencies { get; set; }
} }

View File

@@ -1,4 +1,5 @@
using System.IO; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using Orchard.Environment.Extensions.Models; using Orchard.Environment.Extensions.Models;
using Orchard.FileSystems.Dependencies; using Orchard.FileSystems.Dependencies;
@@ -59,6 +60,7 @@ namespace Orchard.Environment.Extensions.Loaders {
return new ExtensionProbeEntry { return new ExtensionProbeEntry {
Descriptor = descriptor, Descriptor = descriptor,
Loader = this, Loader = this,
Priority = 100, // Higher priority because assemblies in ~/bin always take precedence
VirtualPath = assemblyPath, VirtualPath = assemblyPath,
VirtualPathDependencies = new[] { assemblyPath }, VirtualPathDependencies = new[] { assemblyPath },
}; };