19

我有以下完美运行的代码:

bundles.Add
(
    new ScriptBundle("~/bundles/scripts")
    .Include
    (
        "~/Scripts/jquery-{version}.js"
        ,"~/Scripts/jquery-ui-{version}.js"
        ,"~/Scripts/jquery.unobtrusive*"
        ,"~/Scripts/jquery.validate*"
        ,"~/Scripts/fullcalendar-1.5.4/fullcalendar.js"
        , "~/Scripts/DataTables-1.9.3/media/js/jquery.dataTables.js"
    )
);

但后来我想使用 {version} 通配符来使用它的所有漂亮功能:

bundles.Add
(
    new ScriptBundle("~/bundles/scripts")
    .Include
    (
        "~/Scripts/jquery-{version}.js"
        ,"~/Scripts/jquery-ui-{version}.js"
        ,"~/Scripts/jquery.unobtrusive*"
        ,"~/Scripts/jquery.validate*"
        , "~/Scripts/fullcalendar-{version}/fullcalendar.js"
        , "~/Scripts/DataTables-{version}/media/js/jquery.dataTables.js"
    )
);

和 BANG,异常,它不起作用,我做错了吗?

编辑

异常信息: System.ArgumentException:

目录不存在。参数名称:directoryVirtualPath

堆:

[ArgumentException:目录不存在。Имя параметра: directoryVirtualPath]
System.Web.Optimization.Bundle.Include(String[] virtualPaths) +40
Aerostar.BundleConfig.RegisterBundles(BundleCollection bundles) 在 c:\Users\Denis\Documents\Visual Studio 2012\Projects\Aerostar\Aerostar \App_Start\BundleConfig.cs:21
Aerostar.MvcApplication.Application_Start() 在 c:\Users\Denis\Documents\Visual Studio 2012\Projects\Aerostar\Aerostar\Global.asax.cs:24

[HttpException(0x80004005):目录不存在。Имя параметра: directoryVirtualPath]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9859725
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +118
System.Web.HttpApplication.InitSpecial( HttpApplicationState 状态,MethodInfo[] 处理程序,IntPtr appContext,HttpContext 上下文)+172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext,HttpContext 上下文)+336
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext)+296

[HttpException(0x80004005):目录不存在。Имя параметра: directoryVirtualPath]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9873912 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

4

1 回答 1

30

没错,目前 {version} 表达式仅支持作为文件的一部分,在进行目录遍历时不使用它。这是我们将考虑在未来版本中修复的问题。

我在 codeplex 上为此提交了一个问题。

如果这是您对我们修复的强烈感受,请投票。

于 2012-09-24T20:38:01.270 回答