I have, however, encountered a small bug. On a default Umbraco site with the Simple Website starter-kit installed I have the following CSS files in place:
Now, your package works as expected with all of the stylesheets except the last one Starterkit. When I try and minify it (or any of the other functions) I get a FileNotFound exception as below:
File not found
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Sitereactor.OptimizeIt.Sprite.Exceptions.FileError: File not found
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
What is the name of the Starterkit you installed? I would like to try and recreate the issue, which seems to revolve around the Starterkit.css.
However, the error seems to come down to a check for images in the stylesheet. It shouldn't crash as in your case, but im thinking the error could be due to a missing image in the CSS.
The start kit was called Simple Starter Kit. Can't seem to see it on the package repo, but it was one of the ones you get as an option when you do a default install of Umbraco 4.7 It is being used with the Sweetas feijoaSkins, which also were one of the skins offered with the default install.
For reference, the problematic stylesheet CSS (if this helps) is:
Can I get you to create a new stylesheet and paste the styles from Starterkit.css into it? Just to make sure whether its a problem with the file itself or the styles within it.
I did as you asked and made a new style-sheet (within Umbraco) and pasted in the styles, and the error occured in the copy too. I should also point out that when trying to minify this stylesheet a file is created that is called .min.css that is empty.
What is weird is that I deleted all the styles in the copy of the style-sheet I'd just created and validated it and yet the error still occured! I also tried renaming the stylesheet (within Umbraco) to a few different names and error still occured.
I then did another test - I created a new style-sheet within Visual Studio and then pasted the styles from Starterkit.css into it and then validated it and that worked! I also tried resaving this style-sheet via Umbraco and re-validated and that also worked. I should point out that it validated fine without errors (and when I added a deliberate error this was picked-up).
For my final test I created another blank stylesheet directly from Umbraco and attempted to validate it - but this also generated an error. It seems like any new style-sheet I create from within Umbraco causes the error, regardless of content.
As a developer myself I find that as puzzling as you must do. All I can think is that it's perhaps to do with line endings or file encoding? Perhaps some are using /n and some /r/w or something like that? Are perhaps VS uses UTF-8 and Umbraco doesn't?
Oh, and I just checked the UmbracoLog table to see if there were any relevant errors in there and found these messages:
At /umbraco/plugins/sitereactor/optimizeit/parsecss.aspx?id=1125&rndo=87.8 (Referred by: http://localhost:1737/umbraco/umbraco.aspx): Sitereactor.OptimizeIt.Sprite.Exceptions.FileError: File not found at Sitereactor.OptimizeIt.Sprite.IO.LineReader..ctor(String filePath, String source, IEnumerable`1 filters) at Sitereactor.OptimizeIt.Sprite.Css.CssParser.ParseStyleSheet() at Sitereactor.OptimizeIt.Sprite.Css.CssParser.get_StyleSheet() at Sitereactor.OptimizeIt.Sprite.Css.CssParser.VerifyImagesInCss() at Sitereactor.OptimizeIt.Sprite.Web.ParseCss.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
At /umbraco/settings/stylesheet/editStylesheet.aspx?id=1125 (Referred by: http://localhost:1737/umbraco/settings/stylesheet/editStylesheet.aspx?id=1125): Sitereactor.OptimizeIt.Sprite.Exceptions.FileError: File not found at Sitereactor.OptimizeIt.Sprite.IO.LineReader..ctor(String filePath, String source, IEnumerable`1 filters) at Sitereactor.OptimizeIt.Sprite.Css.CssParser.ParseStyleSheet() at Sitereactor.OptimizeIt.Sprite.Css.CssParser.get_StyleSheet() at Sitereactor.OptimizeIt.Sprite.Menu.CssMenuButtons.MinifyCssBtnClick(Object sender, ImageClickEventArgs e) at System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) at System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
I wouldn't worry about it - it might just be something localised to my installation. When I get the chance I'll try it on another installation to see if the problem can be replicated. Again, thanks for all your hard work.
Marcus, I never found a solution to the issue. But you can use the ClientDependency Framework (that ships with Umbraco) to perform minification. I've even written a blog post on the subject explaining how. Just note that occasionally it can "break" some stylesheets.
The question I still have is how you exclude certain files? I use Google fonts sometimes or other cdn libraries. They seem to break or not work correctly when using this. Do you have something on that aspect?
Hi. Sorry, I've only used this with simple examples. I guess to exclude elements you would put them in a separate CSS/JS file and not load them through client dependency? There are some docs at http://clientdependency.codeplex.com/documentation
Not working with one particular stylesheet
First, thanks for a great package - really cool!
I have, however, encountered a small bug. On a default Umbraco site with the Simple Website starter-kit installed I have the following CSS files in place:
Now, your package works as expected with all of the stylesheets except the last one Starterkit. When I try and minify it (or any of the other functions) I get a FileNotFound exception as below:
File not found
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: Sitereactor.OptimizeIt.Sprite.Exceptions.FileError: File not found
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
The file does exist on disk and there doesn't seem to be anything particular about it. The full error can be seen below in sreenshot:
Doesn't make much sense to me, but perhaps you can work it out?!
Hi Dan,
What is the name of the Starterkit you installed? I would like to try and recreate the issue, which seems to revolve around the Starterkit.css.
However, the error seems to come down to a check for images in the stylesheet. It shouldn't crash as in your case, but im thinking the error could be due to a missing image in the CSS.
- Morten
Hi Morten,
The start kit was called Simple Starter Kit. Can't seem to see it on the package repo, but it was one of the ones you get as an option when you do a default install of Umbraco 4.7 It is being used with the Sweetas feijoaSkins, which also were one of the skins offered with the default install.
For reference, the problematic stylesheet CSS (if this helps) is:
Hi Dan,
Can I get you to create a new stylesheet and paste the styles from Starterkit.css into it? Just to make sure whether its a problem with the file itself or the styles within it.
Thanks
- Morten
Hi Morten,
I did as you asked and made a new style-sheet (within Umbraco) and pasted in the styles, and the error occured in the copy too. I should also point out that when trying to minify this stylesheet a file is created that is called .min.css that is empty.
What is weird is that I deleted all the styles in the copy of the style-sheet I'd just created and validated it and yet the error still occured! I also tried renaming the stylesheet (within Umbraco) to a few different names and error still occured.
I then did another test - I created a new style-sheet within Visual Studio and then pasted the styles from Starterkit.css into it and then validated it and that worked! I also tried resaving this style-sheet via Umbraco and re-validated and that also worked. I should point out that it validated fine without errors (and when I added a deliberate error this was picked-up).
For my final test I created another blank stylesheet directly from Umbraco and attempted to validate it - but this also generated an error. It seems like any new style-sheet I create from within Umbraco causes the error, regardless of content.
As a developer myself I find that as puzzling as you must do. All I can think is that it's perhaps to do with line endings or file encoding? Perhaps some are using /n and some /r/w or something like that? Are perhaps VS uses UTF-8 and Umbraco doesn't?
Oh, and I just checked the UmbracoLog table to see if there were any relevant errors in there and found these messages:
At /umbraco/plugins/sitereactor/optimizeit/parsecss.aspx?id=1125&rndo=87.8 (Referred by: http://localhost:1737/umbraco/umbraco.aspx): Sitereactor.OptimizeIt.Sprite.Exceptions.FileError: File not found at Sitereactor.OptimizeIt.Sprite.IO.LineReader..ctor(String filePath, String source, IEnumerable`1 filters) at Sitereactor.OptimizeIt.Sprite.Css.CssParser.ParseStyleSheet() at Sitereactor.OptimizeIt.Sprite.Css.CssParser.get_StyleSheet() at Sitereactor.OptimizeIt.Sprite.Css.CssParser.VerifyImagesInCss() at Sitereactor.OptimizeIt.Sprite.Web.ParseCss.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
At /umbraco/settings/stylesheet/editStylesheet.aspx?id=1125 (Referred by: http://localhost:1737/umbraco/settings/stylesheet/editStylesheet.aspx?id=1125): Sitereactor.OptimizeIt.Sprite.Exceptions.FileError: File not found at Sitereactor.OptimizeIt.Sprite.IO.LineReader..ctor(String filePath, String source, IEnumerable`1 filters) at Sitereactor.OptimizeIt.Sprite.Css.CssParser.ParseStyleSheet() at Sitereactor.OptimizeIt.Sprite.Css.CssParser.get_StyleSheet() at Sitereactor.OptimizeIt.Sprite.Menu.CssMenuButtons.MinifyCssBtnClick(Object sender, ImageClickEventArgs e) at System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) at System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
I wouldn't worry about it - it might just be something localised to my installation. When I get the chance I'll try it on another installation to see if the problem can be replicated. Again, thanks for all your hard work.
Was there any solution to this? For some strange reason this works well in one project but not another.
Maybe the new Microsoft optimizer could be an option?
Marcus, I never found a solution to the issue. But you can use the ClientDependency Framework (that ships with Umbraco) to perform minification. I've even written a blog post on the subject explaining how. Just note that occasionally it can "break" some stylesheets.
I tried that but I think I prefer this sicne you can manually pack things. I will read your post thanks.
The question I still have is how you exclude certain files? I use Google fonts sometimes or other cdn libraries. They seem to break or not work correctly
when using this. Do you have something on that aspect?
Hi. Sorry, I've only used this with simple examples. I guess to exclude elements you would put them in a separate CSS/JS file and not load them through client dependency? There are some docs at http://clientdependency.codeplex.com/documentation
Thinking of just using the Visual Studio extension by the author of BlogEngine, sure it is manual but I like having some control over this :).
What I don't get is this. This module works perfectly on one website (same server and all) but not this, I can't understand what I did differently.
is working on a reply...