umbraco / Umbraco-CMS

Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
https://umbraco.com
MIT License
4.4k stars 2.66k forks source link

Media folder missing on fresh 12.2.0 install #14877

Open geoffbeaumont opened 11 months ago

geoffbeaumont commented 11 months ago

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

12.2.0

Bug summary

Installing Umbraco 12.2.0 using NuGet, media directory is not created leading to exception on first start.

Not a showstopper, obviously - just manually creating the missing media directory fixes it - but not going to be a great first impression for anyone trying out Umbraco for the first time.

Specifics

On first start of new clean install, following exception occurs:

DirectoryNotFoundException: [SITE_DIRECTORY]\wwwroot\media\ Microsoft.Extensions.FileProviders.PhysicalFileProvider..ctor(string root, ExclusionFilters filters) Umbraco.Cms.Core.IO.PhysicalFileSystem.Create() Umbraco.Extensions.FileSystemExtensions.TryCreateFileProvider(IFileSystem fileSystem, out IFileProvider fileProvider) Umbraco.Cms.Core.IO.ShadowWrapper.Create() Umbraco.Extensions.FileSystemExtensions.TryCreateFileProvider(IFileSystem fileSystem, out IFileProvider fileProvider) Umbraco.Extensions.ApplicationBuilderExtensions.UseUmbracoMediaFileProvider(IApplicationBuilder app) Umbraco.Cms.Web.Common.ApplicationBuilder.UmbracoApplicationBuilder.RegisterDefaultRequiredMiddleware() Umbraco.Cms.Web.Common.ApplicationBuilder.UmbracoApplicationBuilder.WithMiddleware(Action<IUmbracoApplicationBuilderContext> configureUmbracoMiddleware) TestSite.Startup.Configure(IApplicationBuilder app, IWebHostEnvironment env) in Startup.cs + app.UseUmbraco() System.RuntimeMethodHandle.InvokeMethod(object target, Void** arguments, Signature sig, bool isConstructor) System.Reflection.MethodInvoker.Invoke(object obj, IntPtr* args, BindingFlags invokeAttr) System.Reflection.RuntimeMethodInfo.Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(object instance, IApplicationBuilder builder) Microsoft.WebTools.BrowserLink.Net.HostingStartup+<>c__DisplayClass1_0.<Configure>b__0(IApplicationBuilder app) Microsoft.AspNetCore.Watch.BrowserRefresh.HostingStartup+<>c__DisplayClass1_0.<Configure>b__0(IApplicationBuilder app) Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken) Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken) Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token) Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token) Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host) TestSite.Program.Main(string[] args) in Program.cs + => CreateHostBuilder(args)

Steps to reproduce

Create Umbraco site project in Visual Studio, Umbraco Version 12.2.0. Install NuGet packages/build and run site.

Expected result / actual result

Expected the site to start, any essential folders created by NuGet package or on first start.

Actually, site throws exception due to missing wwwroot/media folder.

github-actions[bot] commented 11 months ago

Hi there @geoffbeaumont!

Firstly, a big thank you for raising this issue. Every piece of feedback we receive helps us to make Umbraco better.

We really appreciate your patience while we wait for our team to have a look at this but we wanted to let you know that we see this and share with you the plan for what comes next.

We wish we could work with everyone directly and assess your issue immediately but we're in the fortunate position of having lots of contributions to work with and only a few humans who are able to do it. We are making progress though and in the meantime, we will keep you in the loop and let you know when we have any questions.

Thanks, from your friendly Umbraco GitHub bot :robot: :slightly_smiling_face:

andr317c commented 11 months ago

Hey! Thanks for reporting the issue ๐Ÿ˜„. I was not able to reproduce on v12.2.0. I tried using Rider and Visual Studio, but my Media folder was created each time.

Can you please provide some steps on how you installed Umbraco? Otherwise, I'm having a hard time reproducing ๐Ÿ™

geoffbeaumont commented 11 months ago

I've seen it on two recent installs - both using Visual Studio templates. In both cases I was creating a package solution, so created a package project and an associated test site using sqlite, but beyond that both were very vanilla clean installs on VS2022, Windows 10. I'll see if I can run through some tests and narrow things down.

miguelcrpinto commented 11 months ago

I had the same issue in all V12 versions and I believe in (at least) the latest V10.

I created a new project(s) using the Umbraco templates in Visual Studio 2022 (latest version)

miguelcrpinto commented 11 months ago

It seems that this was never included in any "modern" version of Umbraco. Yesterday I tried with 9.0.0, 9.5.4 and 10.0.0. In the V9s, the wwwroot is not even created. In V10 it only adds the wwwroot and the favicon.ico.

If you install the UmbracoCms (V8) in a ASP.NET framework project it does add the media folder

sniffdk commented 11 months ago

We've experienced this issue as well, on a clean 12.2.0 install, so it is very much a real problem. We've been installing Umbraco through the VS templates as well ๐Ÿ‘

Zeegaan commented 11 months ago

Hello there ๐Ÿ‘‹ Media folder isn't created when you're creating the project, but it is on the first build: MediaFolderCreated

Above is a gif of me creating a new project with the template, and showing media folder gets created on first dotnet run ๐Ÿ˜

Are you not seeing the media folder after running your project ? ๐Ÿค”

geoffbeaumont commented 11 months ago

No. In my case I'm building and running the project within Visual Studio. Which shouldn't make any difference....

Zeegaan commented 11 months ago

@geoffbeaumont hmmm, could it be file permissions perhaps? Are you on a linux / mac machine? Maybe that it the issue why we seem to be unable to reproduce ๐Ÿค”

geoffbeaumont commented 11 months ago

@geoffbeaumont hmmm, could it be file permissions perhaps? Are you on a linux / mac machine? Maybe that it the issue why we seem to be unable to reproduce ๐Ÿค”

No, Windows 10. Shouldn't be anything to do with file permissions, everything else is created without a problem. It's a very boringly standard Windows dev environment!

miguelcrpinto commented 11 months ago

@Zeegaan I'm running Visual Studio 2022 on windows and I ran my solutions by pressing F5. The folder doesn't get created on run (at least with F5)

andr317c commented 11 months ago

I just tried installing Umbraco version 12.2.0 through Visual Studio 2022 on Windows and afterward, I ran the solution by pressing F5. The media folder was created on run for me ๐Ÿ™. Is there a chance that you can record a video installing Umbraco and running it as well? That way we might be able to see what is going on ๐Ÿ˜„

miguelcrpinto commented 11 months ago

@andr317c in Visual Studio, which launch type did you select? IIS express or Umbraco.Web.UI? That might make a difference.

What version of the Umbraco.Templates do you have installed?

image

miguelcrpinto commented 11 months ago

I think me and @vsilvar figured out why some people have this issue.

@geoffbeaumont when you create a new Umbraco project in VS, which "Development database type" did you select?

The media folder seems to be created as part of the Umbraco install process (and not during project creation or build). Since V12.0.1, if you select "SQL Lite" or "SQL Server Express LocalDB" and do not provide an unattended user email and password, the install process doesn't seem to be executed and the application just tries to render the default page (that requires the media folder).

@Zeegaan was able to run it because the default option for "Development database type" is probably none and this option does not configure any connection string in the appsettings.Development.json making the application trigger the install on the first run and creating the media folder.

geoffbeaumont commented 11 months ago

@miguelcrpinto That would make sense actually - the sites I've been creating are test sites in package solutions, running on SQLite. And I quite likely didn't specifiy an unattended user.

Apologies, I haven't had time to do any testing on this. I'll try to find time to test that theory.

mmusameh commented 4 months ago

I think I've figured out the problem. This happens when you install Umbraco using Visual Studio and choose not to "Put solution and project in same directory"

The default installation using the CLI will choose to put both in the same directory and thus works fine.

image