Bundle.config 可以包含 ScriptBundle 吗?

Can the Bundle.config include ScriptBundles?

我可以在我的 Bundle.config 文件中包含脚本吗?还是仅适用于样式包?

<?xml version="1.0" encoding="utf-8" ?>
<bundles version="1.0">
  <styleBundle path="~/Content/css">
    ...
  </styleBundle>
  <scriptBundle path="~/Scripts">

    Is this possible?

  </scriptBundle>
</bundles>

任何人都可以提供 link 到 Bundle.config 参考,解释可能的标签和结构吗?我已经搜索过,但我所能想到的只是捆绑的 BundleConfig.cs 代码方式,而不是标记。我知道为什么 - 标记方式较旧,甚至可能已弃用。但我想学习标记方式,因为它很常见,我将使用使用旧方法的遗留系统。

don't think it's possible and I think you should really avoid using the XML notation. There are almost no resources regarding that topic on the web. So it might be faster to just rewrite the XML to C#. However, there is a NuGet package that will allow you to configure it via XML. The example can be found on GitHub and on the project site.

这叫做"bundle manifest"。这是一个 XML 文件,位于 ~/bundle.config 并通过 BundleManifest.ReadBundleManifest(); 加载到您的 Application_Start.

有一个XSD in CodePlex, named BundleManifestSchema.xsd:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="BundleConfig" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:complexType name="include">
    <xs:attribute name="path" type="xs:string" use="required" />
  </xs:complexType>

  <xs:complexType name="styleBundle">
    <xs:sequence>
      <xs:element name="include" type="include" minOccurs="1" maxOccurs="unbounded" />
    </xs:sequence>
    <xs:attribute name="path" type="xs:string" use="required" />
    <xs:attribute name="cdnPath" type="xs:string" use="optional" />
  </xs:complexType>

  <xs:complexType name="scriptBundle">
    <xs:sequence>
      <xs:element name="include" type="include" minOccurs="1" maxOccurs="unbounded" />
    </xs:sequence>
    <xs:attribute name="path" type="xs:string" use="required" />
    <xs:attribute name="cdnPath" type="xs:string" use="optional" />
    <xs:attribute name="cdnFallbackExpression" type="xs:string" use="optional" />
  </xs:complexType>

  <xs:element name="bundles">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element type="styleBundle" name="styleBundle" />
        <xs:element type="scriptBundle" name="scriptBundle" />
      </xs:choice>
      <xs:attribute name="version" type="xs:string" />
    </xs:complexType>
  </xs:element>

</xs:schema>

是的,支持 scriptBundle