From e375ab4b1b3444bdff13cdc74b41ec48f53d32b2 Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Tue, 20 Dec 2022 07:00:07 +0100 Subject: [PATCH] Added new ContentAndWebRootFileProviderFactory and use that for IManifestFileProviderFactory, so manifests can be found in /app_plugins folder too (#13597) Fixes https://github.com/umbraco/Umbraco-CMS/issues/13565 --- .../UmbracoBuilderExtensions.cs | 2 +- .../ContentAndWebRootFileProviderFactory.cs | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/Umbraco.Web.Common/FileProviders/ContentAndWebRootFileProviderFactory.cs diff --git a/src/Umbraco.Web.Common/DependencyInjection/UmbracoBuilderExtensions.cs b/src/Umbraco.Web.Common/DependencyInjection/UmbracoBuilderExtensions.cs index edfe999d20..dc94fa3dc8 100644 --- a/src/Umbraco.Web.Common/DependencyInjection/UmbracoBuilderExtensions.cs +++ b/src/Umbraco.Web.Common/DependencyInjection/UmbracoBuilderExtensions.cs @@ -149,7 +149,7 @@ public static partial class UmbracoBuilderExtensions // WebRootFileProviderFactory is just a wrapper around the IWebHostEnvironment.WebRootFileProvider, // therefore no need to register it as singleton - builder.Services.AddSingleton(); + builder.Services.AddSingleton(); builder.Services.AddSingleton(); // Must be added here because DbProviderFactories is netstandard 2.1 so cannot exist in Infra for now diff --git a/src/Umbraco.Web.Common/FileProviders/ContentAndWebRootFileProviderFactory.cs b/src/Umbraco.Web.Common/FileProviders/ContentAndWebRootFileProviderFactory.cs new file mode 100644 index 0000000000..7c3831b919 --- /dev/null +++ b/src/Umbraco.Web.Common/FileProviders/ContentAndWebRootFileProviderFactory.cs @@ -0,0 +1,27 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.FileProviders; +using Umbraco.Cms.Core.IO; + +namespace Umbraco.Cms.Web.Common.FileProviders; + +public class ContentAndWebRootFileProviderFactory : IManifestFileProviderFactory +{ + private readonly IWebHostEnvironment _webHostEnvironment; + + /// + /// Initializes a new instance of the class. + /// + /// The web hosting environment an application is running in. + public ContentAndWebRootFileProviderFactory(IWebHostEnvironment webHostEnvironment) + { + _webHostEnvironment = webHostEnvironment; + } + + /// + /// Creates a new instance, pointing at WebRootPath and ContentRootPath. + /// + /// + /// The newly created instance. + /// + public IFileProvider Create() => new CompositeFileProvider(_webHostEnvironment.WebRootFileProvider, _webHostEnvironment.ContentRootFileProvider); +}