ASP.NET MVC ScriptBundle添加了jquery 2.0.2,即使指定了2.0.3

时间:2014-01-02 21:54:51

标签: jquery asp.net-mvc asp.net-mvc-5 scriptbundle

当我在本地运行我的应用程序时,javascript引用按预期工作,但是当我将它部署到我们的开发服务器时,它会在2.0.3引用之前添加jquery 2.0.2引用。

为什么要添加这个?

我猜它不应该干扰,因为它首先加载...... 2.0.3中的任何内容都应该覆盖以前版本中的任何内容,但似乎没必要。

包文件:

<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Antlr" version="3.5.0.2" targetFramework="net45" />
<package id="bootstrap" version="3.0.3" targetFramework="net45" />
<package id="jQuery" version="2.0.3" targetFramework="net45" />
<package id="Microsoft.AspNet.Mvc" version="5.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="3.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.2" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi" version="5.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebHelpers" version="3.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages" version="3.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages.Data" version="3.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages.WebData" version="3.0.0" targetFramework="net45" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="5.0.8" targetFramework="net45" />
<package id="Twitter.Bootstrap" version="3.0.1.1" targetFramework="net45" />
<package id="WebGrease" version="1.5.2" targetFramework="net45" />
</packages>

BundleConfig:

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

本地运行时的输出:

<script src="/MyProject/Scripts/jquery-2.0.3.js"></script>
<script src="/MyProject/Scripts/bootstrap.js"></script>
<script src="/MyProject/Scripts/bootstrap-windows.js"></script>
<script src="/MyProject/Scripts/MyProject.js"></script>

在开发服务器上输出:

<script src="/MyProject/Scripts/jquery-2.0.2.js"></script>
<script src="/MyProject/Scripts/jquery-2.0.3.js"></script>
<script src="/MyProject/Scripts/bootstrap.js"></script>
<script src="/MyProject/Scripts/bootstrap-windows.js"></script>
<script src="/MyProject/Scripts/MyProject.js"></script>

1 个答案:

答案 0 :(得分:4)

可能是/MyProject/Scripts/jquery-2.0.2.js实际存在于磁盘上的开发服务器上吗? {version}的{​​{1}}通配符会导致它被包含在内。

有关捆绑的更多信息,您可以查看Bundling and Minification on www.asp.net