3

When using ASP.NET MVC Bundling/Minification if there is an issue bundling a particular file, then this file will simply be skipped and missed out of the rendered bundle.

So far reasons I know for this are:

  • File not found
  • Invalid syntax

Is there anyway of logging this so that I can identify why particular files are sometimes not being included?

Curtis
  • 101,612
  • 66
  • 270
  • 352
  • What do you mean by 'Syntax Issues'? – haim770 Dec 15 '14 at 12:21
  • @haim770 Invalid syntax – Curtis Dec 15 '14 at 12:55
  • @Curt One approach (perhaps overkill, but very customizable) could be a custom bundler. [Here is some example code on Github](https://github.com/MikeSmithDev/LicensedBundler/blob/master/LicensedBundler/LicensedScriptBundle.cs) and you can see on line 44 where you can catch the errors. – MikeSmithDev Dec 16 '14 at 02:42
  • It's not a complete duplicate of [Asp.Net MVC Bundling, best way to detect missing file](http://stackoverflow.com/q/23802800/33051) as that only answers half the problem... – Zhaph - Ben Duguid Dec 18 '14 at 10:16

1 Answers1

0

Looking through the source for System.Web.Optimization files that aren't correctly minified should be noted in the rendered output through the JsMinify.GenerateErrorResponse method with a comment block as follows:

/*
Each Minify Error happens
On a new line
But it's basiclly obj.ToString() on the errors collection
*/

But none of the default processors throw (or log) any explicit issues unless your virtual paths are malformed.

Digging around a bit I found this answer here on Stack Overflow that shows an custom extension method you could use to handle this - you could adapt that to log issues rather than throwing exceptions if you'd like the rest of the application to continue running.

Community
  • 1
  • 1
Zhaph - Ben Duguid
  • 26,785
  • 5
  • 80
  • 117
  • Thanks Zhaph, however this doesn't cover files which are not found. How can I report on this? – Curtis Dec 17 '14 at 11:23
  • @Curt Sadly there doesn't appear to be anything that to support that - even ReSharper 8 isn't showing me broken virtual paths (like it does for Views and images). – Zhaph - Ben Duguid Dec 18 '14 at 10:10