问题描述
在Windows Azure的发布我选择的设置:
In the Windows Azure Publish Settings I have selected:
Environment: Production
Build Configuration: Release
在我Web.Release.config我有:
In my Web.Release.config I have:
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
我以前绑定工作,我再没code的变化,我知道的。但是现在
当我发布到云和浏览网页,似乎没有捆绑的。
所有的JavaScript和CSS下载一个接一个。
I had bundling working before and I made no code changes that I know of. However nowwhen I publish to the cloud and view web pages it seems there is no bundling at all.All the javascript and CSS are downloaded one by one.
有我丢失的东西?这曾经工作,现在看来不上班
所有。
Is there something I am missing? This used to work and now it seems not to work atall.
我是否需要明确设置如下:
Do I need to explicitly set the following:
<compilation debug="false" targetFramework="4.0">
或者这样:
public static void RegisterBundles(BundleCollection bundles) {
...
...
BundleTable.EnableOptimizations = true;
}
请注意,当我说上面这行我得到一个消息,说:EnableOptimizations是一个属性,但使用像一个类型
Note that when I added the above line I got a message saying: EnableOptimizations is a property but is used like a type.
推荐答案
在web配置调试设置为false
Set debug to false in web config
<compilation debug="false" targetFramework="4.0">
和预期它应该工作!
哦,还有一件事:
BundleTable.EnableOptimizations = true;
覆盖web.config设置,因此,如果这是设置为true,Web.Config中设置调试它应该正常工作。
Overrides Web.Config settings, so if this is set to true and Web.Config is set to debug it should work as well.
如果您想使用,请检查您实际添加BundleTable ......在正确的地方,像这样的:
If you want to use that, check that you actually added BundleTable... in the right place, like this:
public static void RegisterBundles(BundleCollection bundles)
{
BundleTable.EnableOptimizations = true;
编辑:包括工作BundleConfig参考
using System.Web;
using System.Web.Optimization;
namespace YourNameSpace
{
public class BundleConfig
{
// For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/wf").Include(
"~/Scripts/jquery-{version}.js",
"~/Scripts/jquery-ui-{version}.js",
"~/Scripts/jquery.unobtrusive*",
"~/Scripts/jquery.validate*",
"~/Scripts/jquery.wf.overrides.js",
"~/Scripts/popup.unobtrusive.js"));
BundleTable.EnableOptimizations = true;
}
}
}
这篇关于ASP MVC4和天青 - 捆绑和缩小停止工作对我来说,当我发布天青的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!