Debugging MVC 5.1 is not disabled. Combining and minimizing

Starting debugging with VS 2013.2RTM Pro, MVC 5.1 application.

If compilation mode is set to debug = "true", it is assumed that it disables merging and minimization, but this is not the case. When I examine the view source on the page, styles and scripts are included.
<script src="/bundles/modernizr?v=K-FFpFNtIXjnmlQamnX3qHX_A5r984M2xbAgcuEm38iv41"></script>

If I set BundleTable.EnableOptimizations = false; in BundleConfig.cs, it disables merging and minimization, but that’s not how it should work. I should not forget to switch the setting of EnableOptimizations !

Everything works correctly in VS 2012 MVC 4 applications.

Is this a MVC 5.1 bug? Who else has this problem? Is there a way to get debugging information in order to disable combining and minimization?

web.config:

  <system.web> <authentication mode="None" /> <compilation debug="true" targetFramework="4.5" /> <httpRuntime targetFramework="4.5" useFullyQualifiedRedirectUrl="true" maxRequestLength="100000" enableVersionHeader="false" /> <sessionState cookieName="My_SessionId" /> <httpModules> <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" /> <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" /> <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" /> </httpModules> </system.web> 

_Layout.cshtml:

In the title

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

At the end of the body

@Scripts.Render("~/bundles/jquery") @Scripts.Render("~/bundles/jqueryui") @Scripts.Render("~/bundles/jqueryval")

+6
source share
2 answers

I also see this in the release. To get around this, I use conditional flags to achieve the same effect.

  BundleTable.EnableOptimizations = true; #if DEBUG BundleTable.EnableOptimizations = false; #endif 
0
source

You can take a look at this article http://codemares.blogspot.com.eg/2012/03/disable-minification-with-mvc-4-bundles.html

or you can use this simple implementation

 public class NoMinifyTransform : JsMinify { public override void Process(BundleContext context, BundleResponse response) { context.EnableOptimizations = false; var enableInstrumentation = context.EnableInstrumentation; context.EnableInstrumentation = true; base.Process(context, response); context.EnableInstrumentation = enableInstrumentation; } } 

and then when defining script packages in (App_Start) you can use a base Bundle class like this

  IBundleTransform jsTransformer; #if DEBUG BundleTable.EnableOptimizations = false; jsTransformer = new NoMinifyTransform(); #else jstransformer = new JsMinify(); #endif bundles.Add(new Bundle("~/TestBundle/alljs", jsTransformer) .Include("~/Scripts/a.js") .Include("~/Scripts/b.js") .Include("~/Scripts/c.js")); 
0
source

Source: https://habr.com/ru/post/969414/


All Articles