In the Windows Azure Publish Settings I have selected:
Environment: Production
Build Configuration: Release
In my Web.Release.config I have:
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
I had bundling working before and I made no code changes that I know of. However now
when 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 at
all.
Do I need to explicitly set the following:
<compilation debug="false" targetFramework="4.0">
Or this:
public static void RegisterBundles(BundleCollection bundles) {
...
...
BundleTable.EnableOptimizations = true;
}
Note that when I added the above line I got a message saying: EnableOptimizations is a property but is used like a type.
Set debug to false in web config
<compilation debug="false" targetFramework="4.0">
And it should work as expected!
Oh, one more thing:
BundleTable.EnableOptimizations = true;
Overrides Web.Config settings, so if this is set to true and Web.Config is set to debug it should work as well.
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;
EDIT: Including a working BundleConfig for reference
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;
}
}
}