Search code examples
javascriptasp.net-mvccssmonobundling-and-minification

Stylesheets and scripts bundles not working in Mono


Background: I am migrating an ASP.NET MVC 5 application (developed in Windows 8.1, VS2013 Community, .NET 4.5.1, MySql custom membership and role provider) project to Monodevelop (in Ubuntu 14.4, Monodevelop, Mono).

In my ~/App_Start/BundleConfig class

public static void RegisterBundles(BundleCollection bundles)
    {
        BundleTable.EnableOptimizations = true;

     bundles.Add(new StyleBundle("~/Content/css").Include(
                  "~/Content/bootstrap.css",
                  "~/Content/site.css"));

        bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                    "~/Scripts/modernizr-*"));
    }

In my ~/Views/Shared/_Layout.cshtml view

@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")

In my Web.Config

<add namespace="System.Web.Optimization" />

Also

<compilation defaultLanguage="C#" debug="false"> </compilation>

Also Microsoft.Web.Infrastructure.dll is deleted from the bin directory.

Problem: I don't see that the bundles are getting rendered when I view source in the browser:

The links are directing towards directories, It should show files in the directories

<link href="/Content/css" rel="stylesheet"/>
<script src="/bundles/modernizr"></script>

This bundling is working very fine on Windows but on Ubuntu, I see only directories

What am I doing wrong here?


Solution

  • Inside your BundleConfig file add the following:

    BundleTable.EnableOptimizations = true;
    

    Then switch to release mode.

    This should do the trick