mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-14 19:04:51 +08:00
Fix dynamic compilation issue
Don't try to load references that have been already loaded by extension loaders. This bug was affecting compiling of modules depending on other modules (e.g. Orchard.Widgets depends on Orchard.Scripting). If Orchard.Scripting has been loaded by the dynamic compilation loader, don't try to load the "Orchard.Scripting" assembly. --HG-- branch : dev
This commit is contained in:
@@ -58,26 +58,38 @@ namespace Orchard.Environment.Extensions.Compilers {
|
||||
context.AssemblyBuilder.AddCodeCompileUnit(CreateCompileUnit(filename));
|
||||
}
|
||||
|
||||
var addedReferences = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
// Add assembly references
|
||||
foreach (var reference in dependencyDescriptor.References) {
|
||||
var referenceTemp = reference;
|
||||
var loader = _loaders.SingleOrDefault(l => l.Name == referenceTemp.LoaderName);
|
||||
if (loader != null) {
|
||||
var assembly = loader.LoadReference(reference);
|
||||
if (assembly != null) {
|
||||
context.AssemblyBuilder.AddAssemblyReference(assembly);
|
||||
}
|
||||
}
|
||||
if (loader == null) {
|
||||
Logger.Warning("Could not find loader '{0}' in active loaders", reference.LoaderName);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Load references specified in project file
|
||||
var assembly = loader.LoadReference(reference);
|
||||
if (assembly == null) {
|
||||
Logger.Warning("Loader '{0}' could not load reference '{1}'", reference.LoaderName, reference.Name);
|
||||
continue;
|
||||
}
|
||||
|
||||
addedReferences.Add(reference.Name);
|
||||
context.AssemblyBuilder.AddAssemblyReference(assembly);
|
||||
}
|
||||
|
||||
// Load references specified in project file (only the ones not yet loaded)
|
||||
foreach (var assemblyReference in projectFileDescriptor.References) {
|
||||
if (addedReferences.Contains(assemblyReference.SimpleName))
|
||||
continue;
|
||||
|
||||
var assembly = _assemblyLoader.Load(assemblyReference.FullName);
|
||||
if (assembly != null) {
|
||||
context.AssemblyBuilder.AddAssemblyReference(assembly);
|
||||
}
|
||||
else {
|
||||
Logger.Warning("Assembly reference '{0}' for project '{1}' cannot be loaded", assemblyReference.FullName, context.VirtualPath);
|
||||
Logger.Error("Assembly reference '{0}' for project '{1}' cannot be loaded", assemblyReference.FullName, context.VirtualPath);
|
||||
throw new OrchardCoreException(T(
|
||||
"The assembly reference '{0}' could not be loaded.\r\n\r\n" +
|
||||
"There are generally a few ways to solve this issue:\r\n" +
|
||||
|
Reference in New Issue
Block a user