新的.NET特性捆绑和压缩功能中,{版本}通配符无法与目录一起使用?

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

然后,异常出现了,它不起作用,我做错了什么吗?

编辑

异常信息: System.ArgumentException:

目录不存在。 参数名: directoryVirtualPath

堆栈:

[ArgumentException: 目录不存在。参数名:directoryVirtualPath]
System.Web.Optimization.Bundle.Include(String[] virtualPaths) +40
Aerostar.BundleConfig.RegisterBundles(BundleCollection bundles) in c:\Users\Denis\Documents\Visual Studio 2012\Projects\Aerostar\Aerostar\App_Start\BundleConfig.cs:21
Aerostar.MvcApplication.Application_Start() in 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 state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +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


这可能对任何阅读此内容的人有帮助,知道“什么”异常。=) - J. Steen
抱歉,我已经编辑了问题。 - Lu4
1个回答

30

没错,目前{version}表达式只在文件中支持使用,不能在目录遍历时使用。我们会在未来的版本中修复这个问题。

我已经在Codeplex上提交了这个问题

如果你认为这是一个重要的问题,希望你能为它投票。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接