mlang
mlang

Reputation: 159

Orchard - Can't find the Resource defined in ResourceManifest.cs

I have a custom there, where I try to require some of my css and js files via the ResourceManifest.cs file - I keep into running a quite weird issue tough.

I get the following error:

a 'script' named 'FoundationScript' could not be found

This is my ResourceManifest.cs:

using Orchard.UI.Resources;

namespace Themes.TestTheme
{
  public class ResourceManifest : IResourceManifestProvider
  {
    public void BuildManifest(ResourceManifestBuilder builder)
    {

      var manifest = builder.Add();

      manifest.DefineStyle("Foundation").SetUrl("foundation.min.css");
      manifest.DefineScript("FoundationScript").SetUrl("foundation.min.js");

    }  
  }
}

In the Layout.cshtml, I have following:

@{
  Script.Require("ShapesBase");
  Script.Require("FoundationScript");

  Style.Include("site.css");
  Style.Require("Foundation");

}

What am I missing here?

Upvotes: 2

Views: 1327

Answers (1)

Behnam Esmaili
Behnam Esmaili

Reputation: 5967

The issue here is, that the project Themes has a problem with the dynamic compile mechanism of Orchard (i don't know what is wrong exactly) because it resides in folder Themes. Even if you define a class inside the Themes assembly, it will result in an error telling you there is no such class in that assembly.

solution :

Try re-generating your theme with /CreateProject:true and /IncludeInSolution:true parameters as follows:

codegen theme TestTheme /CreateProject:true /IncludeInSolution:true /BasedOn :TheThemeMachine

It will create your theme in a separate project and orchard will pick your registered ResourceManifest.

Hope this helps.

Upvotes: 1

Related Questions