2013-11-26 1 views
-1

Когда я переключаюсь на запуск без отладки, мой пакет не включает правильный путь в html. он отбрасывает имя файла.установка debug = 'false' в web.config вызывает сбои в сбое

using System.Web; 
using System.Web.Optimization; 

namespace Search 
{ 
    public class BundleConfig 
    { 
     // For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725 
     public static void RegisterBundles(BundleCollection bundles) 
     { 
      bundles.UseCdn = true; 

      var jqueryuiCdnPath = "http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.3/jquery-ui.min.js"; 
      var knockoutCdnPath = "http://ajax.aspnetcdn.com/ajax/knockout/knockout-2.2.1.js"; 
      var modernizerCdnPath = ""; 

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

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

      bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
         "~/Scripts/jquery.unobtrusive*", 
         "~/Scripts/jquery.validate*")); 

      bundles.Add(new ScriptBundle("~/bundles/knockout", knockoutCdnPath).Include(
       "~/Scripts/knockout-2.1.0.debug.js")); 

      // Use the development version of Modernizr to develop with and learn from. Then, when you're 
      // ready for production, use the build tool at http://modernizr.com to pick only the tests you need. 
      bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
         "~/Scripts/modernizr-*")); 

      bundles.Add(new ScriptBundle("~/bundles/scpa").Include(
      "~/Scripts/scpa.js")); 


      bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/NewSite.css").Include("~/Content/PagedList.css")); 


      bundles.Add(new StyleBundle("~/Content/themes/redmond").Include(
         "~/Content/themes/redmond/jquery-ui-{version}.custom.css")); 
     } 
    } 
} 

Эти строки в моей _layout.cshtml

@Styles.Render("~/content/themes/redmond") 
    @Styles.Render("~/content/css") 

Сформировать следующий HTML с поддержкой отладки

<link href="/Content/themes/redmond/jquery-ui-1.10.3.custom.css" rel="stylesheet"/> 
<link href="/Content/NewSite.css" rel="stylesheet"/> 
<link href="/Content/PagedList.css" rel="stylesheet"/> 

однако при отладке от этого генерируется

<link href="/content/themes/redmond?v=vAH9QfqxdFYSzS_GtpWa8fGJ5s-xvZ9vhODh9AGxIbo1" rel="stylesheet"/> 
<link href="/content/css?v=3o7zDFviiGqrSMyW4LTNH-J9tRGdIoONnnh_FMEm4Mg1" rel="stylesheet"/> 
+1

Пожалуйста, объясните ваши вниз голоса. –

ответ

8

Это как это предполагается быть сгенерированным.

Хотя ваш первый пучок, вероятно, не работает - вы не можете указать имя пакета с тем же именем, что и существующая папка. Переименуйте второй StyleBundle, как:

bundles.Add(new StyleBundle("~/Content/cssRedmond").Include(... 

, потому что он генерирует ссылка будет работать, потому что не конфликтует с другой папкой:

<link href="/content/cssRedmond?v=..." //This is OK 
<link href="/content/themes/redmond?v=..." //Not OK. Conflicts with folder 
+0

Спасибо за вашу помощь, я не понял из-за чтения о том, что он полностью удалит ссылку на имя файла для выпуска. –

+1

@ Mr.Manager - это часть «связывания» ... файлы минитируются/объединены в один файл. Таким образом, теперь клиенту нужно только загрузить один файл вместо нескольких файлов. – MikeSmithDev