Skip to content

Commit

Permalink
Fixes application view paths. (#3087)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtkech authored and sebastienros committed Jan 25, 2019
1 parent 47fcb67 commit 1fb1e46
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/OrchardCore/OrchardCore.Mvc.Core/ShellViewFeatureProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,38 @@ public void PopulateFeature(IEnumerable<ApplicationPart> parts, ViewsFeature fea
{
var assembly = Assembly.LoadFile(precompiledAssemblyPath);

var applicationPart = new ApplicationPart[] { new CompiledRazorAssemblyPart(assembly) };

foreach (var provider in mvcFeatureProviders)
{
provider.PopulateFeature(new ApplicationPart[] { new CompiledRazorAssemblyPart(assembly) }, moduleFeature);
provider.PopulateFeature(applicationPart, moduleFeature);
}

// Razor views are precompiled in the context of their modules, but at runtime
// their paths need to be relative to the virtual "Areas/{ModuleId}" folders.
// Note: For the app's module this folder is "Areas/{env.ApplicationName}".
foreach (var descriptor in moduleFeature.ViewDescriptors)
{
descriptor.RelativePath = '/' + module.SubPath + descriptor.RelativePath;
feature.ViewDescriptors.Add(descriptor);
}

// For the app's module we still allow to explicitly specify view paths relative to the app content root.
// So for the application's module we re-apply the feature providers without updating the relative paths.
// Note: This is only needed in prod mode if app's views are precompiled and views files no longer exist.
if (module.Name == _hostingEnvironment.ApplicationName)
{
foreach (var provider in mvcFeatureProviders)
{
provider.PopulateFeature(applicationPart, moduleFeature);
}

foreach (var descriptor in moduleFeature.ViewDescriptors)
{
feature.ViewDescriptors.Add(descriptor);
}
}

moduleFeature.ViewDescriptors.Clear();
}
catch (FileLoadException)
Expand Down

0 comments on commit 1fb1e46

Please sign in to comment.