2012-06-04 22 views
0

我想將所有腳本合併成一個..我有兩個文件夾,主文件夾'腳本'和其他'腳本/其他'。ScriptBundle不包括取決於訂購的其他腳本

當我嘗試:

BundleTable.Bundles.Add(new ScriptBundle("~/scripts/all").Include("~/Scripts/*.js", "~/Scripts/other/*.js")); 

從 '腳本/其他' 不包括腳本。 但是當我反轉的順序:

BundleTable.Bundles.Add(new ScriptBundle("~/scripts/all").Include("~/Scripts/other/*.js", "~/Scripts/*.js")); 

它的工作原理!有人可以告訴我爲什麼?

+0

你可以給我一個repro? – RickAndMSFT

+0

我正試圖找到這個項目。 – MuriloKunze

回答

1

我不知道發生了什麼,但是這是System.Web.Optimization.Bundle裏面的代碼:

// System.Web.Optimization.Bundle 
public Bundle Include(params string[] virtualPaths) 
{ 
    for (int i = 0; i < virtualPaths.Length; i++) 
    { 
     string text = virtualPaths[i]; 
     Exception ex = Bundle.ValidateVirtualPath(text, "virtualPaths"); 
     if (ex != null) 
     { 
      throw ex; 
     } 
     if (text.Contains('*')) 
     { 
      int num = text.LastIndexOf('/'); 
      string text2 = text.Substring(0, num); 
      if (text2.Contains('*')) 
      { 
       throw new  ArgumentException(string.Format(CultureInfo.CurrentCulture,  OptimizationResources.InvalidPattern, new object[] 
       { 
       text 
      }), "virtualPaths"); 
     } 
     string text3 = ""; 
     if (num < text.Length - 1) 
     { 
      text3 = text.Substring(num + 1); 
     } 
     PatternType patternType = PatternHelper.GetPatternType(text3); 
     ex = PatternHelper.ValidatePattern(patternType, text3, "virtualPaths"); 
     if (ex != null) 
     { 
      throw ex; 
     } 
     this.IncludeDirectory(text2, text3); 
    } 
    else 
    { 
     this.IncludeFile(text); 
    } 
} 
return this; 
} 
5

你可以嘗試直接調用IncludeDirectory方法和看到,如果你看到同樣的問題?

ScriptBundle("~/scripts/all").IncludeDirectory("~/Scripts", "*.js").IncludeDirectory("~/Scripts/other", "*.js")); 

如果這個工作,那麼我們可能在這裏有一個錯誤。