19
votes

I have the following pice of code which runs perfectly:

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

But then I want to use the {version} wildcard to use all of it's nifty features:

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

and BANG, exception, it doesn't work, am I doing something wrong?

EDIT

Exception info: System.ArgumentException:

Directory does not exist. Parameter name: directoryVirtualPath

Stack:

[ArgumentException: Directory does not exist. Имя параметра: 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): Directory does not exist. Имя параметра: 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): Directory does not exist. Имя параметра: directoryVirtualPath]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9873912 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

1
It'll might be helpful for anyone reading this to know what exception. =)J. Steen
Sorry, I've edited the questionLu4

1 Answers

30
votes

That is correct, currently the {version} expression is only supported as part of the file, its not used while doing directory walking. This is something that we will look into fixing in a future version.

I filed an issue for this here on codeplex.

Please vote it up if this is something you feel strongly about us fixing.