Reputation: 12452
I encountered this annoying error telling me that .less files are not stylesheets. Oh Yea.
BundleTransformer.Core.Validators.InvalidAssetTypesException : These assets are not style sheets : 'Site/Content/Stylesheets/Less/style.less'
I have BundleTransformer.Less ( as 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();
Transforms.Add(_cssTransformer);
Transforms.Add(_cssMinify);
}
}
And layout rendering :
@Styles.Render("~/SiteCSS")
Anyone encounter same problem ? Thanks a lot for any advice.
Upvotes: 4
Views: 1067
Reputation: 21
Install nuget package BundleTransformer.Less. It will resolve the issue.
check package.config
Upvotes: 2
Reputation: 1286
Check your the Web.config
file. There should be the following settings:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<bundleTransformer xmlns="http://tempuri.org/BundleTransformer.Configuration.xsd">
<core ...>
<css ...>
...
<fileExtensions>
<add fileExtension=".css" assetTypeCode="Css" />
<add fileExtension=".less" assetTypeCode="Less" />
...
</fileExtensions>
...
</css>
...
</core>
</bundleTransformer>
</configuration>
Also I do not recommend to write your own LessStyleBundle
class. Better to use the BundleTransformer.Core.Bundles.CustomStyleBundle
class and install the BundleTransformer.MicrosoftAjax module (after installation please read the readme.txt
file).
Upvotes: 4