OrchardCMS / OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
https://orchardcore.net
BSD 3-Clause "New" or "Revised" License
7.42k stars 2.39k forks source link

Shape type '_Edit' view not found on custom feature/module #11506

Closed briziomusic closed 2 years ago

briziomusic commented 2 years ago

Describe the bug

Hello, I'm trying to understand and develop a module with a feature in OrchardCoreCms. I have downloaded the source code of 1.3 version (but I have also tested it on 1.2) and i received this error

Exception: Shape type 'AWSS3MediaSettings_Edit' not found.

Basicly this is an implementation of the media file storage on AWS S3 and i want to set all the parameters in the admin dashboard. I'm new with OC so i would like to understand how it works, debugging OC source code and implementing new modules. I start developing with OrchardCore.Cms.web project. What I'm expecting is I think a reference error or someting similar because, if i develop the feature inside the OrchardCore path (solution path src/OrchardCore.Modules.Cms) everything works fine, but if i move my project outside of the that path (in my case src/Custom/OrchardCore.Modules.Cms) i had a lot of problems. First of all I have discovered all the project that must be included inside my feature csproj file. I hade some errors about targetframework, view and wwwroot that are not be visible inside the project. Finally I'm now able to see my module from the list of features and enabled it. But when i click in the settings of the custom features i receive shape type not found

To Reproduce

Steps to reproduce the behavior:

  1. Download my solution here and open OrchardCore.sln
  2. Rebuild 'OrchardCore.Cms.Web' project and run it.
  3. Setup the default tenant (i'm not in the default tenant)
  4. Search 'amazon' in the feature list and enable the feature.
  5. Expand the media link in the sidebar of the admin theme and click on AWS S3 Media Options and receive error

Expected behavior

No errors. Same behavior of the module running at the Orchard core source path.

Screenshots

Screenshot

Thank you

Skrypt commented 2 years ago

Using source code may be a little more complex than simply using a NuGet package solution because you don't have to bother about a lot of details.

Here, first thing, the custom modules that you are creating requires to be standing inside the OrchardCore.Modules folder and the themes need to be standing in the OrchardCore.Themes folder. This, is because we use Directory.Build.props and Directory.Build.target files in these folders to define common dependencies for these.

Also, when you want to add a custom project to the source code you need to either add a reference directly to your custom module in the OrchardCore.Cms.Web project OR add the reference inside OrchardCore.Application.Cms.Targets project that is used for defining common dependencies for a Web project. You can alternatively create a custom "target" project that regroups all your custom modules and add a reference to that project to the OrchardCore.Cms.Web project.

But looking at your current solution, I think the issue is that you have put all your custom projects inside the wrong folders. I would start by moving those into the appropriate folders and see what happens.

Skrypt commented 2 years ago

Also, one solution would be to copy over these Directory.Build.props and Directory.Build.target files in your custom folder(s) where they are supposed to be and to modify them so that they point to the right path.

briziomusic commented 2 years ago

Thank you @Skrypt for you support. So basicly is not possible to develop custom modules/features outside of the OC folders. Actually in the beginning I created all inside OC folders and everything worked like a charm. What you have suggested about creating a 'custom target' project seem to be a nice solution. What I'm trying to reach is to keep everything developed by me, outside the OC folders so it will be more easy to upgrade the entire framework.

Thank you really much

jptissot commented 2 years ago

Have a look at an old project I worked on where we use the nuget packages and mimic OC's build system.

https://github.com/StatCan/StatCan.OrchardCore

ns8482e commented 2 years ago

@briziomusic use code generation templates using dotnet new

Skrypt commented 2 years ago

Compiling the entire source code is not recommended for work productivity. It is always faster to use a NuGet package solution and to customize modules for your own needs if required by using different techniques like overrides. And, the StatCan project is a good example of how to keep the same folder structure to make it simpler. My own project uses the same kind of approach but it is really a mirror copy of the folder structure of the main repository to be able to reuse some CI scripts and else.

Maybe it would be worth using this approach in the current OrchardCore.Samples project.

Also tried at some point to use this approach with the OrchardCore.Commerce module but it was not the right time.

briziomusic commented 2 years ago

@Skrypt yes I know that is not reccomanded using source codes. Every code changes requires a lot of time. But it is very useful in the beginning just to see how something is implemented and I can easily replicate on my modules.