本文介绍了试图创建新的软件包时,NoTransform不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下面一个例子,创建一个MVC项目自定义软件包时,无法获得NoTransform工作。这里是我的code,因为NoTransform产生一个错误,指出,错误1类型或命名空间名称'NoTransform那不​​会编译找不到(是否缺少using指令或程序集引用?)。有什么想法?

 使用系统;
使用System.Collections.Generic;
使用System.Configuration;
使用System.Data.Entity的;
使用System.Data.Entity.Infrastructure;
使用System.Linq的;
使用的System.Web;
使用System.Web.Http;
使用System.Web.WebPages;
使用System.Web.Mvc;
使用System.Web.Optimization;
使用System.Web.Routing;命名空间CoyleAzure
{
    公共类MvcApplication:System.Web.HttpApplication
    {
        保护无效的Application_Start()
        {
            AreaRegistration.RegisterAllAreas();            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            //添加添加DisplayModes
            DisplayModeProvider.Instance.Modes.Insert(0,新DefaultDisplayMode(手机)
            {
                ContextCondition =(上下文=>(
                (context.GetOverriddenUserAgent()!= NULL)及和放大器;
                (
                (context.GetOverriddenUserAgent()的IndexOf(简称iPhone,StringComparison.OrdinalIgnoreCase)GT; = 0)||
                (context.GetOverriddenUserAgent()的IndexOf(iPod的,StringComparison.OrdinalIgnoreCase)GT; = 0)||
                    (context.GetOverriddenUserAgent()的IndexOf(德罗伊德,StringComparison.OrdinalIgnoreCase)GT; = 0)||
                        (context.GetOverriddenUserAgent()的IndexOf(黑莓,StringComparison.OrdinalIgnoreCase)GT; = 0)||
                            (context.GetOverriddenUserAgent()。StartsWith(黑莓,StringComparison.OrdinalIgnoreCase))
            )
            ))
            });
            DisplayModeProvider.Instance.Modes.Insert(0,新DefaultDisplayMode(平板电脑)
            {
                ContextCondition =(上下文=>(
                    (context.GetOverriddenUserAgent()!= NULL)及和放大器;
                    (
                    (context.GetOverriddenUserAgent()的IndexOf(iPad是,StringComparison.OrdinalIgnoreCase)GT; = 0)||
                    (context.GetOverriddenUserAgent()的IndexOf(剧本,StringComparison.OrdinalIgnoreCase)GT; = 0)||
                        (context.GetOverriddenUserAgent()的IndexOf(变压器,StringComparison.OrdinalIgnoreCase)GT; = 0)||
                            (context.GetOverriddenUserAgent()的IndexOf(Xoom的,StringComparison.OrdinalIgnoreCase)GT; = 0)
                        )
                        ))
            });            IBundleTransform jsTransformer;
            IBundleTransform cssTransformer;#如果DEBUG
            jsTransformer =新NoTransform(文/ JavaScript的);
            cssTransformer =新NoTransform(文/ CSS);
#其他
            jsTransformer =新JsMinify();
            cssTransformer =新CssMinify();
#万一            VAR
            DesktopJSBundle =新包(〜/脚本/ DesktopJS,jsTransformer);            DesktopJSBundle.Include(〜/脚本/ jQuery的-1.6.4的js。);
            DesktopJSBundle.Include(〜/脚本/ jQuery的-UI-1.8.11 JS。);
            DesktopJSBundle.Include(〜/脚本/ jquery.unobtrusive-ajax.js);
            DesktopJSBundle.Include(〜/脚本/ jquery.validate.js);
            DesktopJSBundle.Include(〜/脚本/ jquery.validate.unobtrusive.js);            BundleTable.Bundles.Add(DesktopJSBundle);            VAR DesktopCSSBundle =新包(〜/内容/ DesktopCSS,cssTransformer);
            DesktopCSSBundle.Include(〜/内容/的site.css);
            BundleTable.Bundles.Add(DesktopCSSBundle);            VAR MobileJSBundle =新包(〜/脚本/ MobileJS,jsTransformer);
            MobileJSBundle.Include(〜/脚本/ jQuery的-1.6.4.js);
            MobileJSBundle.Include(〜/脚本/ jquery.mobile-1.1.0.js);
            BundleTable.Bundles.Add(MobileJSBundle);            VAR MobileCSSBundle =新包(〜/内容/ MobileCSS,cssTransformer);
            MobileCSSBundle.Include(〜/内容/ jquery.mobile-1.1.0.css);
            MobileCSSBundle.Include(〜/内容/ jquery.mobile.structure-1.1.0.css);
            BundleTable.Bundles.Add(MobileCSSBundle);
            //BundleTable.Bundles.RegisterTemplateBundles();
            BundleTable.Bundles.EnableDefaultBundles();
        }
        //BundleConfig.RegisterBundles(BundleTable.Bundles);
    }
}


解决方案

不是直接回答这个只是指出来的人谁在未来编遇到这个......它可以通过配置来完成为好, (请参见)

 <&的System.Web GT;
    <编译调试=真/>
    &所述;! - 为了清楚而移除行。 - >
< /system.web>

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);




    }
}
解决方案

not a direct answer to this but just to point it out to anyone who comes across this in the furture... it can be done via config as well, (see http://stackoverflow.com/a/12605451/6486)

<system.web>
    <compilation debug="true" />
    <!-- Lines removed for clarity. -->
</system.web>

这篇关于试图创建新的软件包时,NoTransform不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 01:30