Custom theme recipe.json not detected
Describe the bug
When following the readme to create a custom theme, and including a <myTheme>.recipe.json file, with 'issetuprecipe': true, the theme is not in the startup collection.
Orchard Core version
2.2.1 / Visual Studio 2022 /Visual Studio 2026
To Reproduce
- Follow the readme steps to create a new theme
- Add/Edit the recipe.json file
- Include the project in the Cms.Web project dependencies
- Start the Cms.Web project, debug the recipe harvester, check found recipes when the 'path' matches the <myTheme> project - no recipes are found.
If you then:
- Copy the recipe file to one of the other themes and start: The new recipe IS visible (twice) in the drop down.
- Delete the copied recipe file from the Orchard theme and start. The new recipe is still visible twice.
- Rebuild the solution and restart: The new recipe is visible ONCE in the drop down, debugging The Recipe harvester shows it being found within the correct project path.
Expected behavior
Recipe is detected by the Recipe Harvester class and displayed in the setup dropdown list of available recipes.
Could you please upload the recipe here? Also, please verify that you use the file name pattern "example.recipe.json" and not "example.recipie.json".
I can confirm that the typo's are just in the text above. Recipe file attached. I can't work out why it isn't detected until it is copied to an existing theme, then removed from that theme. I tried creating a new theme using the orchard commands, and straight in VS as a new project, checked all the project settings and file settings matched existing themes...
I checked it out, and there's nothing wrong with the recipe itself. Do note that the Media files references there should have a correct path relative to the recipe, even if you move it.
I suspect maybe the build action of the file is wrong in the original project. Be sure to set it as Embedded resource, what should be the default:
Or, your theme is not detected by OC (and the recipe being detected when you move it back and forth just means it gets stuck in the other theme somehow). What happens if you set up the site with one of the built-in recipes, can you see your theme listed under Themes on the admin? If not, double check that you have the following package reference in the theme project at least:
<PackageReference Include="OrchardCore.Theme.Targets" Version="2.2.1" />
Also, from what you describe, it seems to me that you use OC from source. Instead, the recommended way is to include the OC NuGet packages in an ASP.NET Core project. See https://docs.orchardcore.net/en/latest/guides/create-cms-application/ and https://www.youtube.com/watch?v=cQJeS21wZHw&list=PLuskKJW0FhJcSX7j0Bd-1X5hq3dgCtYwO&index=3.
BTW the site looks like a good fit to be hosted on https://dotnest.com/. Much easier than taking care of hosting and maintaining OC yourself.
Yes, the build action is correct, and I am referencing OrchardCore.Theme.Targets. I am using the source code version for development as it allows me to easily see how everything in other themes and modules is done. I haven't yet been able to work out why the recipe is not initially seen on new projects. On the plus side, I do have a workaround, but it is a very strange issue that had me stumped for a few hours!
What happens if you set up the site with one of the built-in recipes, can you see your theme listed under Themes on the admin?
It seems that this issue didn't really move for quite a while despite us asking the author for further feedback. Is this something you'd like to revisit any time soon or should we close? Please reply.
Apologies, hadnt had chance to catch up. The answer is no, Visual Studio does not detect it, even in thr admin panel (it is marked as a setup recipie) I am using the source code, and did try creating a new theme via the cmd tools and by adding a project manually. As mentioned, ive still no idea why the juggling of files resolves the issue.
Just to clarify: I'm asking about the theme (not the recipe) being visible on the admin of OC (not in VS) in the grid under the Design -> Themes menu. The theme being detected is a prerequisite to anything in it being detected.
From what you describe in the latest comment, you're likely mixing a theme project that references the OC NuGet packages with the full source. Don't use the full source unless you're working on OC itself as a contribution; rather, use the OC NuGet packages.
The Initialize-OrchardCoreSolution script from Lombiq Utility Scripts project will generate a solution like this for you, with a theme and module included. I recommend you start with that, to avoid some basic issues.