NoTransform isn't working when trying to create new Bundle

asp.net, asp.net-mvc, asp.net-optimization, bundle

Solution

The `NoTransform` class no longer needs to be public because starting in RC, a null `Transform` class on `Bundle` implicitly means `NoTransform`.

Before:

new Bundle("~/yourbundle", new NoTransform())

Now:

new Bundle("~/yourbundle")

We felt it was cleaner to not require a dummy instance. We kept it internal because it has a tiny bit of logic that would potentially cause some trouble, since the Transform is responsible for setting the contentType for the response. The default logic uses the file extension of the first file in your bundle (.js/.css).

Also with the addition of the Script/Styles Render helpers, you should no longer need to dynamically switch between different transforms based on debug=true|false. The helpers should take care of that for you.

Problem

I am following an example and cannot get the "NoTransform" to work when creating a custom bundle for an MVC project. Here is my code that won't compile because of the "NoTransform" yielding an error that says, "Error 1 The type or namespace name 'NoTransform' could not be found (are you missing a using directive or an assembly reference?)". Any thoughts? ``` using System; using System.Collections.Generic; using System.Configuration; using System.Data.Entity; using System.Data.Entity.Infrastructure; using System.Linq; using System.Web; using System.Web.Http; using System.Web.WebPages; using System.Web.Mvc; using System.Web.Optimization; using System.Web.Routing; namespace CoyleAzure { public class MvcApplication : System.Web.HttpApplication { protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); // Added to Add DisplayModes DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("Phone") { ContextCondition = (context => ( (context.GetOverriddenUserAgent() != null) && ( (context.GetOverriddenUserAgent().IndexOf("iPhone", StringComparison.OrdinalIgnoreCase) >= 0) || (context.GetOverriddenUserAgent().IndexOf("iPod", StringComparison.OrdinalIgnoreCase) >= 0) || (context.GetOverriddenUserAgent().IndexOf("Droid", StringComparison.OrdinalIgnoreCase) >= 0) || (context.GetOverriddenUserAgent().IndexOf("Blackberry", StringComparison.OrdinalIgnoreCase) >= 0) || (context.GetOverriddenUserAgent().StartsWith("Blackberry", StringComparison.OrdinalIgnoreCase)) ) )) }); DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("Tablet") { ContextCondition = (context => ( (context.GetOverriddenUserAgent() != null) && ( (context.GetOverriddenUserAgent().IndexOf("iPad", StringComparison.OrdinalIgnoreCase) >= 0) || (context.GetOverriddenUserAgent().IndexOf("Playbook", StringComparison.OrdinalIgnoreCase) >= 0) || (context.GetOverriddenUserAgent().IndexOf("Transformer", StringComparison.OrdinalIgnoreCase) >= 0) || (context.GetOverriddenUserAgent().IndexOf("Xoom", StringComparison.OrdinalIgnoreCase) >= 0) ) )) }); IBundleTransform jsTransformer; IBundleTransform cssTransformer; #if DEBUG jsTransformer = new NoTransform("text/javascript"); cssTransformer = new NoTransform("text/css"); #else   jsTransformer = new JsMinify();   cssTransformer = new CssMinify(); #endif var DesktopJSBundle = new Bundle("~/Scripts/DesktopJS", jsTransformer); DesktopJSBundle.Include("~/Scripts/jquery-1.6.4. js"); DesktopJSBundle.Include("~/Scripts/jquery-ui-1.8.11. js"); DesktopJSBundle.Include("~/Scripts/jquery.unobtrusive-ajax.js"); DesktopJSBundle.Include("~/Scripts/jquery.validate.js"); DesktopJSBundle.Include("~/Scripts/jquery.validate.unobtrusive.js"); BundleTable.Bundles.Add(DesktopJSBundle); var DesktopCSSBundle = new Bundle("~/Content/DesktopCSS", cssTransformer); DesktopCSSBundle.Include("~/Content/Site.css"); BundleTable.Bundles.Add(DesktopCSSBundle); var MobileJSBundle = new Bundle("~/Scripts/MobileJS", jsTransformer); MobileJSBundle.Include("~/Scripts/jquery-1.6.4.js"); MobileJSBundle.Include("~/Scripts/jquery.mobile-1.1.0.js"); BundleTable.Bundles.Add(MobileJSBundle); var MobileCSSBundle = new Bundle("~/Content/MobileCSS", cssTransformer); MobileCSSBundle.Include("~/Content/jquery.mobile-1.1.0.css"); MobileCSSBundle.Include("~/Content/jquery.mobile.structure-1.1.0.css"); BundleTable.Bundles.Add(MobileCSSBundle); //BundleTable.Bundles.RegisterTemplateBundles(); BundleTable.Bundles.EnableDefaultBundles(); } //BundleConfig.RegisterBundles(BundleTable.Bundles); } } ```

Original source

Related problems