Orchard CMS failing to discover resources defined in a theme after Publish from Visual Studio

371 Views Asked by At

So, I tried to Publish (both Web Deploy and File System) an Orchard instance. I have quite a few custom modules and a custom theme. I have ResourceManifest : IResourceManifestProvider in my theme's project. Yes the theme has its own project and it is included in the solution. The Scripts and Styles I defined are working beautifully when I debug it and work on my dev environment. So far so good.

Today I tried to setup a test environment of the current version. So I tried to get only the most essential without copy/pasting the whole folder structure. Naturally I tried to Publish the Orchard.Web project. And after a short struggle to get right permissions applied...it worked and I could access the site. Unfortunately when I navigated to one of my custom pages that has Style.Require("Resource defined in the theme") it crashed with an error message that a resource with the name "bla bla" cannot be found.

I tried to Publish both a Debug and a Release configuration but it didn't help. I tried to move the styles from the Theme project to a more concrete CustomModule but it didn't discover it.

Could it be some caching? Should I restart the IIS or only the WebSite in IIS? Somehow these new definitions cannot be detected.

In the end I tried to use Style.Include and it seemed that it won't crash, only to see that when I navigate to my page I receive "The page does not exist message" in the Content area (at least didn't crash)...

I am totally lost with this issue. Any help would be appreciated. I can give you more detailed info just let me know what.

I am running Orchard v.1.8.1.0.

This is my code:

manifest.DefineScript("Bootstrap").SetUrl("http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js");
        manifest.DefineStyle("Bootstrap").SetUrl("http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css");

Error message:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: A 'stylesheet' named 'Bootstrap' could not be found. at Orchard.UI.Resources.ResourceManager.BuildRequiredResources(String resourceType) in

EDIT 03.01.2017

I have abandoned my efforts for quite a while. Today I decided to start battling it again and I found the following:

  1. I moved the resource definitions from the MyThemeProject/ResourceManifest.cs to NonThemeCustomModule/ResourceManifest.cs file (one that I wrote).
  2. I Rebuild and Re-Published using Web Deploy And it was working!!!!

Which is pretty cool and solves my issue, BUT also is quite unexpected, since I have the same definitions twice and Orchard doesn't complain about it. Which leads me to believe that the ResourceManifest file in the theme is not taken into account for some reason. If anyone from the Orchard team can tell me what I am doing wrong, or if it is a bug of Orchard, that would be great.

Cheers!

1

There are 1 best solutions below

1
Serge Dancause On

I've encouter this situation a couple of time with a different scenario tho. In Orchard the application pool may need to have the rights on the folder where ur ressources are stored. Add it to ur security folder, it may be the problem.