自定义脚本包排序错误

本文关键字:排序 错误 脚本 包排序 自定义 | 更新日期: 2023-09-27 17:49:15

我尝试在我的脚本包中添加一个自定义排序,如下所示:http://stevescodingblog.co.uk/changing-the-ordering-for-single-bundles-in-asp-net-4/

但是,在构建项目时,我得到以下错误:

错误1 '命名空间。AsIsBundleOrderer'没有实现接口成员"System.Web.Optimization.IBundleOrderer.OrderFiles (System.Web.Optimization.BundleContext,System.Collections.Generic.IEnumerable)

public class AsIsBundleOrderer : IBundleOrderer
{
    public virtual IEnumerable<FileInfo> OrderFiles(BundleContext context, IEnumerable<FileInfo> files)
    {
        return files;
    }
}
public class BundleConfig
{
    // For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
    public static void RegisterBundles(BundleCollection bundles)
    {
        var bundle = new ScriptBundle("~/bundles/js").Include(
            "~/Scripts/jquery.min.js",
            "~/Scripts/jquery-ui.min.js",
            "~/Scripts/bootstrap.min.js",
            "~/Scripts/jquery.flot.categories.js",
            "~/Scripts/jquery.flot.js",
            "~/Scripts/jquery.flot.min.js",
            "~/Scripts/jquery.flot.orderBars.js",
            "~/Scripts/jquery.flot.pie.js",
            "~/Scripts/jquery.flot.resize.js",
            "~/Scripts/graphtable.js",
            "~/Scripts/fullcalendar.min.js",
            "~/Scripts/chosen.jquery.min.js",
            "~/Scripts/autoresize.jquery.min.js",
            "~/Scripts/jquery.autotab.js",
            "~/Scripts/jquery.jgrowl_minimized.js",
            "~/Scripts/jquery.dataTables.min.js",
            "~/Scripts/jquery.stepy.min.js",
            "~/Scripts/jquery.validate.min.js",
            "~/Scripts/jquery.cookie.js",
            "~/Scripts/raphael.2.1.0.min.js",
            "~/Scripts/justgage.1.0.1.min.js",
            "~/Scripts/glisse.js",
            "~/Scripts/styleswitcher.js",
            "~/Scripts/moderniz.js",
            "~/Scripts/jquery.sparkline.min.js",
            "~/Scripts/slidernav-min.js",
            "~/Scripts/jquery.fancybox.js",
            "~/Scripts/main.js",
            "~/Scripts/application.js",
            "~/Scripts/excanvas.min.js",
            "~/Scripts/float.settings.infobox.js"
        );
        bundle.Orderer = new AsIsBundleOrderer();
        bundles.Add(bundle);

自定义脚本包排序错误

最近对Microsoft.Web.Optimization的更新更改了IBundleOrderer。如果您使用的是最新的软件包(目前是2014年2月20日的1.1.3版本),请输入:

public virtual IEnumerable<FileInfo> OrderFiles

现在应该是:

public virtual IEnumerable<BundleFile> OrderFiles