在 ASP.NET MVC 中定义一些包时对 {version} 感到困惑

Confused about {version} while defining some bundles in ASP.NET MVC

目前我正在测试捆绑包,我知道可以使用 {version}* 等通配符。我不完全确定 {version} 是干什么用的。我假设 * 像正则表达式一样工作,它接受所有匹配所有可能性的东西:jquery* 意味着 jqueryAjquery-ui.js 等所有东西。我只是想有选择的可能性我的 javascript 库、css 文件等的开发版本或生产版本。以下是文件结构:

Content\
        css\
            bootstrap-theme.css
            bootstrap-theme-min.css
            bootstrap.css
            bootstrap.min.css

the same with Scripts:

Scripts\
        jquery-2.1.3.js
        jquery-2.1.3.min.js
        jquery-ui.js
        jquery-ui.min.js

我定义了以下包,但我觉得 {version} 完全错误或在字符串中的错误位置:

bundles.Add(new ScriptBundle("~/bundles/jquery").Include("~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include("~/Scripts/jquery-ui{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include("~/Scripts/modernizr-*"));

bundles.Add(new StyleBundle("~/bundles/css/Bootstrap").Include("~/Content/css/bootstrap-theme{version}.css"));
bundles.Add(new StyleBundle("~/bundles/css/Bootstrap").Include("~/Content/css/bootstrap{version}.css"));
bundles.Add(new StyleBundle("~/bundles/css").Include("~/Content/StyleSheet.css"));

如何指示 ASP.NET 在应用程序的发布版本中替换 bootstrap.css 而不是 bootstrap.min.css

谢谢!

{version}有点像通配符,但它做了两件额外的事情,它将通配符限制为看起来像版本号的东西(例如“1.2.3”),并且它使用它找到的最高版本。这允许您拥有同一脚本的多个版本,并且捆绑器将始终使用最新版本。

例如,如果您有以下内容:

Scripts\
+ jquery-1.10.1.js
+ jquery-1.10.2.js
+ jquery-2.0.0.js

还有一个脚本包,例如:

bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
    "~/Scripts/jquery-{version}.js");

然后,~/Scripts/jquery-2.0.0.js 将被添加到捆绑包中。