These assets are not a style sheet bug in BundleTransformer

I ran into this annoying error telling me that .less files are not style sheets. Oh yeah.

BundleTransformer.Core.Validators.InvalidAssetTypesException: These assets are not stylesheets: "Site / Content / Stylesheets / Less / style.less

I have BundleTransformer.Less (as a package).

My BundleConfig.cs:

bundles.Add(new LessStyleBundle("~/SiteCSS").IncludeDirectory("~/Content/Stylesheets/Less", "*.less"));


My LessStyleBundle class:

 public sealed class LessStyleBundle : StyleBundle

        private static readonly IBundleTransform _cssTransformer = new StyleTransformer();
        private static readonly IBundleTransform _cssMinify = new CssMinify();

        public LessStyleBundle(string virtualPath)
            : base(virtualPath)
            Orderer = new NullOrderer();


And rendering the layout:



Does anyone face the same problem? Thanks a lot for any advice.


source to share

2 answers

Check the file Web.config

. There should be the following settings:

<?xml version="1.0" encoding="utf-8"?>
    <bundleTransformer xmlns="">
        <core ...>
            <css ...>
                    <add fileExtension=".css" assetTypeCode="Css" />
                    <add fileExtension=".less" assetTypeCode="Less" />


Also, I don't recommend writing your own LessStyleBundle

class. Better to use the class BundleTransformer.Core.Bundles.CustomStyleBundle

and install the BundleTransformer.MicrosoftAjax module (read the file after installation readme.txt




Install the nuget BundleTransformer.Less package. This will fix the problem.

check package.config



All Articles