我有debug="true"我的web.config(s),我只是不希望我的捆绑缩小,但我做的任何事情似乎都禁用它.我试过了enableoptimisations=false,这是我的代码:
//Javascript
bundles.Add(new ScriptBundle("~/bundles/MainJS")
.Include("~/Scripts/regular/lib/mvc/jquery.validate.unobtrusive.js*")
.Include("~/Scripts/regular/lib/mvc/jquery.validate*")
.Include("~/Scripts/regular/lib/bootstrap.js")
.IncludeDirectory("~/Scripts/regular/modules", "*.js", true)
.IncludeDirectory("~/Scripts/regular/pages", "*.js", true)
.IncludeDirectory("~/Scripts/regular/misc", "*.js", true));
//CSS
bundles.Add(new StyleBundle("~/bundles/MainCSS")
.Include("~/Content/css/regular/lib/bootstrap.css*")
.IncludeDirectory("~/Content/css/regular/modules", "*.css", true)
.IncludeDirectory("~/Content/css/regular/pages", "*.css", true))
Run Code Online (Sandbox Code Playgroud) asp.net asp.net-mvc bundle asp.net-mvc-4 asp.net-optimization
我希望能够在生产环境中缩小/捆绑我的javascript文件,同时在本地调试时让它们不受限制/非捆绑; 但是,VS2012中的默认WebForms站点似乎不允许它.
重现我的问题的步骤:
MsAjaxJS和WebFormsJsweb.config,默认情况下有:
<compilation debug="true" targetFramework="4.5">
Run Code Online (Sandbox Code Playgroud)
我甚至尝试通过明确告诉BundleTable不要优化来修改Global.asax :
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
BundleTable.EnableOptimizations = false;
BundleConfig.RegisterBundles(BundleTable.Bundles);
AuthConfig.RegisterOpenAuth();
RouteConfig.RegisterRoutes(RouteTable.Routes);
}
Run Code Online (Sandbox Code Playgroud)
然而,我仍然得到不可判断的javascript文件:

这个站点(我意识到它是用于MVC)告诉我,无论是debug="true"在web.config还是BundleTable.EnableOptimizations = false;在Global.asax中,都应关闭该功能.而这个网站,(这是对WebForms和从第一个链接),并没有提到将其关闭进行调试.
我怎么能(干净地)告诉我的项目只在debug ="false"时缩小/捆绑?
(我正在使用ASP.NET 4.5)
编辑:
这个问题和这个问题是相似的,但他们都只提供使用的解决方案Scripts.Render().有没有办法用模板化的ScriptManager方法完成这个?