0

当我在本地运行我的应用程序时,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>

捆绑配置:

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>
4

1 回答 1

4

/MyProject/Scripts/jquery-2.0.2.js不是真的存在于磁盘上,在开发服务器上?{version}通配符 of然后.Include("~/Scripts/jquery-{version}.js")会导致它被包含在内。

有关捆绑的更多信息,您可能需要查看www.asp.net 上的捆绑和缩小

于 2014-01-02T22:05:38.953 回答