Hi I am trying to bundle my scripts for my application. My debug is working and if I publish with the Web.debug every thing works fine. But when I publish with the Web.releas my
In my case of missing stylesheets, the problem was not due to the vagaries of publication to Azure, failures during minification or conflicting virtual and real paths.
It was due to the different behaviours of BundleCollection.Add(Bundle)
between Debug and Release.
If you manage to do the following (for example, because you're using Durandal from NuGet and have multiple BundleConfig's initialized by WebActivator, and you didn't really write any of them yourself)
bundles.Add(new StyleBundle("/foo").Include("/a.css"));
bundles.Add(new StyleBundle("/foo").Include("/b.css"));
Basically, if the bundles don't minify, this works: you get elements in your Razor page for both /foo/a.css
and /foo/b.css
.
But if minification is engaged, then b.css
doesn't make it into the resulting minified resource. (or is a.css
replaced ... I wasn't paying attention ... just trying to get it to work).
You can work around this by understanding the order of loading and using:
bundles.Add(new StyleBundle("/foo").Include("/a.css"));
bundles.Add(bundles.GetBundleFor("/foo").Include("/b.css"));
... or by using a different named path (if that's really your intention), or refining your strategy to bundling initialization (which may potentially break NuGet updates).
If only the stupid 'documentation' for System.Web.Optimization
classes actually bothered to specify the behaviour of adding multiple bundles with the same virtual path, we need not be having this discussion.