0

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">
Brian Rogers
  • 142
  • 2
  • 9

1 Answers1

3

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" ... />
Jeremy Cook
  • 20,840
  • 9
  • 71
  • 77
  • There is no debug attribute set in the Production/QA web.configs. – Brian Rogers Apr 17 '14 at 19:37
  • 1
    Have you tried explicitly specifying it just to be sure you've ruled out that issue? Your web.config may be picking up the setting from another web.config or machine.config further up the chain. – Jeremy Cook Apr 17 '14 at 19:39
  • That was it! I checked `machine.config` and `web.config` in `C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Config` and found no debug attribute set. I checked the root of the site, though, and found a `web.config` with `debug=true` in it. – Brian Rogers Apr 17 '14 at 19:49
  • Glad to help. Don't you love how web.config settings can be inherited from completely unrelated parent applications? – Jeremy Cook Apr 17 '14 at 19:51
  • Editing your answer to include that, then marking as answer. – Brian Rogers Apr 17 '14 at 19:52
  • 1
    Consider voting for [option for sub applications to opt-out of web.config inheritance from parent application](http://aspnet.uservoice.com/forums/41199-general-asp-net/suggestions/5792801-option-for-sub-applications-to-opt-out-of-web-conf) – Jeremy Cook Apr 17 '14 at 20:14