asp.net-mvcasp.net-mvc-3asp.net-mvc-4system.web.optimization

Why would bundles not bundle on one server?


Why would bundles render bundled and minified on one server but not on another server? QA and Production are both the same OS and version of IIS, but they give different results. In QA, Styles.Render() and Scripts.Render() generate bundled, minified output. In Production they usually don't (but sometimes do).

I have this line in my layout.

@Scripts.Render("~/siteJs")

In development, I expect and get this output.

<script src="/MyApp/Scripts/jquery.placeholder.js"></script>
<script src="/MyApp/Scripts/Site.js"></script>

On the QA server, I expect and get this.

<script src="/MyApp/siteJs?v=7-G_q9YBnk..."></script>

But in Production, I usually (but not always) get the dev output.

<script src="/MyApp/Scripts/jquery.placeholder.js"></script>
<script src="/MyApp/Scripts/Site.js"></script>

To try to reproduce, I deleted the web app from QA and deployed Production binaries and configs to QA, but still QA gave me the expected output. I've seen this in multiple web applications, both MVC3 and MVC4.

I can force it to reliably minify and bundle by changing the line in my layout to this.

@Scripts.Render(BundleTable.Bundles.ResolveBundleUrl("~/siteJs"))

This, unfortunately, always bundles and minifies, even in development.

EDIT:

The Debug is not set in the Production and QA web.config files.

<compilation targetFramework="4.0">

Solution

  • On production, ensure that debug is set to false in web.config. Setting it to true in development should change your output.

    <compilation debug="false" ... />