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.41k stars 2.66k forks source link

[V14] Extension with alias Extension.EntryPoint is already registered #15959

Open enkelmedia opened 5 months ago

enkelmedia commented 5 months ago

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

v14

Bug summary

I'm working on a extension for Umbraco 14 and after moving my "proof of concept"-code for Bellissima in to a upgraded branch that used to run fine on v13 i noticed an error that I did not see during proof of concept work.

The browser console would throw: Extension with alias Extension.EntryPoint is already registered

The problem seems to be because of how the umbraco-package.json is loaded using WebHostingEnvironment.WebRootFileProvider.

Specifics

I made some more in depth research and it turn out that the problem was that I had an old folder in the consuming website with a different casing.

Here is a screenshot from the solution.

  1. The "NewsletterStudio" project is a Razor Class Library where there is a App_Plugins-folder with the name newsletterStudio.
  2. The "NewsletterStudio.TestSite" project is the Umbraco CMS website that contains a App_Plugins-folder with the name NewsletterStudio (notice the difference in case).

image

I added a simple view to explore what the WebRootFileProvider finds in the application:

...
@inject Microsoft.AspNetCore.Hosting.IWebHostEnvironment HostingEnvironment
@{
    Layout = null;
    var res = WebHostingEnvironment.WebRootFileProvider.GetDirectoryContents("App_Plugins");
}
@if(res.Exists)
{
    <ul>
    @foreach (var item in res)
        {
            <li>@item.Name</li>
        }
    </ul>
}
else
{
    <p>Not exists</p>
}

The result looked like this:

image

Since I'm on a Window-machine the files returned by these two calls are the same

Basically, the same umbraco-package.json is loaded twice since there are two folders with the same name and on my Windows 11 machine the same file is returned for both these calls. I 've not tested this on Linux/Mac.

Steps to reproduce

Run the v14 backoffice and notice that the error is shown since the code that loads the umbraco-package files will load the plugin twice.

Expected result / actual result

The umbraco-package.json file should only be loaded once.

One could say that this is an issue with my solution setup but I could see scenarios for other packages where a developer using the package might add a folder with a casing that does not match the one in the RCL which would cause the same issue.

I can see different solutions and I think it depends on how the scenario would work on a file system that is case sensitive. IF the filesystem is case sensitive (Linux/Mac) it would probably be theoretically possible to have two different extensions in folders where the casing is the only difference, definitely not a good idea but it would be possible.

Ideas for solution:

Let me know if you need any further details!

// Markus

github-actions[bot] commented 5 months ago

Hi there @enkelmedia!

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:

Zeegaan commented 5 months ago

Hmmm that's tricky one, I will bring this one up with the team to discuss 😁