Documentation

Embedded resources

The BundleCollection.AddEmbeddedResources method adds a bundle of embedded resources to the collection.


bundles.AddEmbeddedResources<ScriptBundle>("~/MyResources",
    // Assembly containing resources
    Assembly.GetExecutingAssembly(),

    // Base namespace of resources
    // Default namespace of the assembly plus any parent directory names
    "MyApp.Resources",
    
    // All the resource files to combine
    "resource1.js",
    "resource2.js",
    // ...
);

Embedded resource bundles behave similarly to standard Cassette bundles, except references between files are not used, and you need to explicitly specify all the references to bundle.

An embedded resource can be added to a regular bundle by adding a ResourceAsset to the bundle:


bundles.Add<StylesheetBundle>("~/MyBundle", new[]
{
    // All the standard CSS files to bundle
    "Content/css/example1.css",
    "Content/css/example2.css",
}, bundle =>
{
    var assembly = GetType().Assembly;
    // Add all the embedded resources
    bundle.Assets.Add(new ResourceAsset("MyApp.Resources.css.example3.less", assembly));
    bundle.Assets.Add(new ResourceAsset("MyApp.Resources.css.example4.less", assembly));
});