OrchardCore icon indicating copy to clipboard operation
OrchardCore copied to clipboard

Document that the web project's `wwwroot` folder needs to be pre-created (like with a placeholder)

Open canadacubachina opened this issue 1 year ago • 9 comments

Describe the bug

The cache root path cannot be determined, make sure it's explicitly configured or the webroot is set. at SixLabors.ImageSharp.Web.Caching.PhysicalFileSystemCache.GetCacheRoot(PhysicalFileSystemCacheOptions cacheOptions, String webRootPath, String contentRootPath)

Orchard Core version

OC: 2.1.3 AZURE APP SERVICE LINUX STANDARD .NET 8.0.301 AZURE SQL SERVER STANDARD

To Reproduce

  1. Ref OC 2.1.3
  2. Deploy to Azure App Service ( github action)
  3. Show Set up Page without problem
    1. choose Blog recipe, got 500, 4.2. or choose SaaS, it is ok , then go to admin panel, enable media (Cache) features.
  4. See error HTTP ERROR 500

Expected behavior

WHEN GOT HTTP ERROR 500, WHOLE SITE IS DOWN. 1-- do not know why The WebRootPath was not found, can someone help me? 2--for GetCacheRoot(PhysicalFileSystemCacheOptions cacheOptions, String webRootPath, String contentRootPath) maybe we can use default value for String webRootPath, or String contentRootPath for double guarantee.

Logs and screenshots

2025-01-12 19:20:53.7153|||16|Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware|WARN|The WebRootPath was not found: /home/site/wwwroot/wwwroot. Static files may be unavailable. 2025-01-12 19:20:53.9024|||14|Microsoft.Hosting.Lifetime|INFO|Now listening on: http://[::]:8080 2025-01-12 19:20:53.9147||||Microsoft.Hosting.Lifetime|INFO|Application started. Press Ctrl+C to shut down. 2025-01-12 19:20:53.9211||||Microsoft.Hosting.Lifetime|INFO|Hosting environment: Production 2025-01-12 19:20:53.9218||||Microsoft.Hosting.Lifetime|INFO|Content root path: /home/site/wwwroot 2025-01-12 19:35:14.2578|||16|Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware|WARN|The WebRootPath was not found: /home/site/wwwroot/wwwroot. Static files may be unavailable. 2025-01-12 19:35:14.4482|||14|Microsoft.Hosting.Lifetime|INFO|Now listening on: http://[::]:8080 2025-01-12 19:35:14.4653||||Microsoft.Hosting.Lifetime|INFO|Application started. Press Ctrl+C to shut down. 2025-01-12 19:35:14.4661||||Microsoft.Hosting.Lifetime|INFO|Hosting environment: Production 2025-01-12 19:35:14.4661||||Microsoft.Hosting.Lifetime|INFO|Content root path: /home/site/wwwroot 2025-01-12 19:55:19.0373|||16|Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware|WARN|The WebRootPath was not found: /home/site/wwwroot/wwwroot. Static files may be unavailable. 2025-01-12 19:55:19.2170|||14|Microsoft.Hosting.Lifetime|INFO|Now listening on: http://[::]:8080 2025-01-12 19:55:19.2280||||Microsoft.Hosting.Lifetime|INFO|Application started. Press Ctrl+C to shut down. 2025-01-12 19:55:19.2344||||Microsoft.Hosting.Lifetime|INFO|Hosting environment: Production 2025-01-12 19:55:19.2344||||Microsoft.Hosting.Lifetime|INFO|Content root path: /home/site/wwwroot

2025-01-12 20:36:01.3452|Default|00-ad542db524a0a257a0a1553511a87d7a-7cf3278d6f740d61-00|13|Microsoft.AspNetCore.Server.Kestrel|ERROR|Connection id "0HN9J8C5H3QL7", Request id "0HN9J8C5H3QL7:00000002": An unhandled exception was thrown by the application. System.InvalidOperationException: The cache root path cannot be determined, make sure it's explicitly configured or the webroot is set. at SixLabors.ImageSharp.Web.Caching.PhysicalFileSystemCache.GetCacheRoot(PhysicalFileSystemCacheOptions cacheOptions, String webRootPath, String contentRootPath) at SixLabors.ImageSharp.Web.Caching.PhysicalFileSystemCache..ctor(IOptions1 options, IWebHostEnvironment environment, FormatUtilities formatUtilities) at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor) at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span1 copyOfArgs, BindingFlags invokeAttr) at System.Reflection.MethodBaseInvoker.InvokeWithFewArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(ServiceIdentifier serviceIdentifier) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(ServiceIdentifier serviceIdentifier, ServiceProviderEngineScope serviceProviderEngineScope) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType) at Microsoft.Extensions.Internal.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider) at Microsoft.Extensions.Internal.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.ReflectionMiddlewareBinder.CreateMiddleware(RequestDelegate next) at Microsoft.AspNetCore.Builder.ApplicationBuilder.Build() at OrchardCore.Modules.ShellPipelineExtensions.BuildPipelineInternalAsync(ShellContext context) at OrchardCore.Modules.ShellPipelineExtensions.BuildPipelineAsync(ShellContext context) at OrchardCore.Modules.ModularTenantRouterMiddleware.Invoke(HttpContext httpContext) at OrchardCore.Modules.ModularTenantContainerMiddleware.<>c__DisplayClass4_0.<b__0>d.MoveNext() --- End of stack trace from previous location --- at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func2 execute, Boolean activateShell) at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func2 execute, Boolean activateShell) at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func2 execute, Boolean activateShell) at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func2 execute, Boolean activateShell) at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func2 execute, Boolean activateShell) at OrchardCore.Modules.ModularTenantContainerMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication1 application) at SixLabors.ImageSharp.Web.Caching.PhysicalFileSystemCache.GetCacheRoot(PhysicalFileSystemCacheOptions cacheOptions, String webRootPath, String contentRootPath) at SixLabors.ImageSharp.Web.Caching.PhysicalFileSystemCache..ctor(IOptions1 options, IWebHostEnvironment environment, FormatUtilities formatUtilities) at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor) at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span1 copyOfArgs, BindingFlags invokeAttr) at System.Reflection.MethodBaseInvoker.InvokeWithFewArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(ServiceIdentifier serviceIdentifier) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(ServiceIdentifier serviceIdentifier, ServiceProviderEngineScope serviceProviderEngineScope) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType) at Microsoft.Extensions.Internal.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider) at Microsoft.Extensions.Internal.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.ReflectionMiddlewareBinder.CreateMiddleware(RequestDelegate next) at Microsoft.AspNetCore.Builder.ApplicationBuilder.Build() at OrchardCore.Modules.ShellPipelineExtensions.BuildPipelineInternalAsync(ShellContext context) at OrchardCore.Modules.ShellPipelineExtensions.BuildPipelineAsync(ShellContext context) at OrchardCore.Modules.ModularTenantRouterMiddleware.Invoke(HttpContext httpContext) at OrchardCore.Modules.ModularTenantContainerMiddleware.<>c__DisplayClass4_0.<b__0>d.MoveNext() --- End of stack trace from previous location --- at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func2 execute, Boolean activateShell) at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func2 execute, Boolean activateShell) at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func2 execute, Boolean activateShell) at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func2 execute, Boolean activateShell) at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func2 execute, Boolean activateShell) at OrchardCore.Modules.ModularTenantContainerMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication1 application)

canadacubachina avatar Jan 12 '25 21:01 canadacubachina

Try to add a wwwroot folder under your web project. It can be empty. Does this fix the issue?

Piedone avatar Jan 13 '25 15:01 Piedone

@Piedone Thank you for your reply. I just made it successful. I think we should put the following on the OrchardCore.Cms.Web.csproj:

<ItemGroup>
  <Content Update="wwwroot\.placeholder">
    <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
  </Content>
</ItemGroup>

What is your idea?

canadacubachina avatar Jan 13 '25 18:01 canadacubachina

There's already a .placeholder files specifically for this. However, this is perhaps worthwhile to point out in the getting started docs. Perhaps something you'd be open to contribute? https://docs.orchardcore.net/en/latest/contributing/contributing-documentation/

Piedone avatar Jan 13 '25 18:01 Piedone

just .placeholder is not enough, should add 👍 <ItemGroup>

<Content Update="wwwroot\.placeholder">
  <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>

canadacubachina avatar Jan 13 '25 20:01 canadacubachina

Hmm, it works without adding anything to the csproj for me. Anyway, that wouldn't hurt.

Piedone avatar Jan 13 '25 20:01 Piedone

https://github.com/OrchardCMS/OrchardCore/pull/17346 doesn't actually completely fix this. We still need the docs, and more importantly, as Sebastien pointed out during today's meeting, in the codegen templates:

  • https://github.com/OrchardCMS/OrchardCore/blob/main/src/Templates/OrchardCore.ProjectTemplates/content/OrchardCore.Templates.Cms.Web/wwwroot/.placeholder
  • https://github.com/OrchardCMS/OrchardCore/blob/main/src/Templates/OrchardCore.ProjectTemplates/content/OrchardCore.Templates.Mvc.Web/wwwroot/.placeholder

Piedone avatar Jan 14 '25 20:01 Piedone

We triaged this issue and set the milestone according to the priority we think is appropriate (see the docs on how we triage and prioritize issues).

This indicates when the core team may start working on it. However, if you'd like to contribute, we'd warmly welcome you to do that anytime. See our guide on contributions here.

github-actions[bot] avatar Jan 16 '25 18:01 github-actions[bot]

I got this error when deploying orchard cms to coolify using nixpacks.

info: OrchardCore.Modules.ModularTenantRouterMiddleware[0]
      Begin Routing Request
warn: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[16]
      The WebRootPath was not found: /app/wwwroot. Static files may be unavailable.
fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[3]
      An exception was thrown attempting to execute the error handler.
      System.InvalidOperationException: The cache root path cannot be determined, make sure it's explicitly configured or the webroot is set.
         at SixLabors.ImageSharp.Web.Caching.PhysicalFileSystemCache.GetCacheRoot(PhysicalFileSystemCacheOptions cacheOptions, String webRootPath, String contentRootPath)
         at SixLabors.ImageSharp.Web.Caching.PhysicalFileSystemCache..ctor(IOptions`1 options, IWebHostEnvironment environment, FormatUtilities formatUtilities)
         at InvokeStub_PhysicalFileSystemCache..ctor(Object, Span`1)
         at System.Reflection.MethodBaseInvoker.InvokeWithFewArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
         at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
         at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
         at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
         at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
         at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(ServiceIdentifier serviceIdentifier)
         at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(ServiceIdentifier serviceIdentifier, ServiceProviderEngineScope serviceProviderEngineScope)
         at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
         at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)
         at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)
         at Microsoft.AspNetCore.Builder.ApplicationBuilder.Build()
         at OrchardCore.Modules.ShellPipelineExtensions.BuildPipelineInternalAsync(ShellContext context)
         at OrchardCore.Modules.ShellPipelineExtensions.BuildPipelineAsync(ShellContext context)
         at OrchardCore.Modules.ModularTenantRouterMiddleware.Invoke(HttpContext httpContext)
         at OrchardCore.Modules.ModularTenantContainerMiddleware.<>c__DisplayClass4_0.<<Invoke>b__0>d.MoveNext()
      --- End of stack trace from previous location ---
         at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
         at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
         at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
         at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
         at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
         at OrchardCore.Modules.ModularTenantContainerMiddleware.Invoke(HttpContext httpContext)
         at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.HandleException(HttpContext context, ExceptionDispatchInfo edi)
fail: Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HNCOH9AV5RFS", Request id "0HNCOH9AV5RFS:00000001": An unhandled exception was thrown by the application.
      System.InvalidOperationException: The cache root path cannot be determined, make sure it's explicitly configured or the webroot is set.
         at SixLabors.ImageSharp.Web.Caching.PhysicalFileSystemCache.GetCacheRoot(PhysicalFileSystemCacheOptions cacheOptions, String webRootPath, String contentRootPath)
         at SixLabors.ImageSharp.Web.Caching.PhysicalFileSystemCache..ctor(IOptions`1 options, IWebHostEnvironment environment, FormatUtilities formatUtilities)
         at InvokeStub_PhysicalFileSystemCache..ctor(Object, Span`1)
         at System.Reflection.MethodBaseInvoker.InvokeWithFewArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
         at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
         at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
         at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
         at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
         at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(ServiceIdentifier serviceIdentifier)
         at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(ServiceIdentifier serviceIdentifier, ServiceProviderEngineScope serviceProviderEngineScope)
         at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
         at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)
         at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)
         at Microsoft.AspNetCore.Builder.ApplicationBuilder.Build()
         at OrchardCore.Modules.ShellPipelineExtensions.BuildPipelineInternalAsync(ShellContext context)
         at OrchardCore.Modules.ShellPipelineExtensions.BuildPipelineAsync(ShellContext context)
         at OrchardCore.Modules.ModularTenantRouterMiddleware.Invoke(HttpContext httpContext)
         at OrchardCore.Modules.ModularTenantContainerMiddleware.<>c__DisplayClass4_0.<<Invoke>b__0>d.MoveNext()
      --- End of stack trace from previous location ---
         at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
         at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
         at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
         at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
         at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
         at OrchardCore.Modules.ModularTenantContainerMiddleware.Invoke(HttpContext httpContext)
         at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.<Invoke>g__Awaited|10_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)
         at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.HandleException(HttpContext context, ExceptionDispatchInfo edi)
         at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.HandleException(HttpContext context, ExceptionDispatchInfo edi)
         at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.<Invoke>g__Awaited|10_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)
         at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
         at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished HTTP/1.1 GET http://<REDACTED>/ - 500 0 - 49.9471ms

lamualfa avatar May 23 '25 07:05 lamualfa

Solved. It turns out you need to run dotnet YourProject.dll in the published folder.

dotnet dist/YourProject.dll => cd dist && dotnet YourProject.dll

lamualfa avatar May 23 '25 07:05 lamualfa