包含有关 VSIX 包中内容类型的信息。 Visual Studio 使用 [Content_Types].xml 文件来安装包,但它不会安装文件本身。
注意
尽管本主题仅适用于 VSIX 包中使用的 [Content_Type].xml 文件,但 [Content_Types].xml 文件类型是开放打包约定 (OPC) 标准的一部分。 有关详细信息,请参阅 OPC:在 MSDN 网站上打包数据 的新标准。
特性和元素
以下部分介绍根元素及其属性和子元素。
Root 元素
| 元素 | 说明 |
|---|---|
Types |
包含枚举 VSIX 包中的文件类型的子元素。 |
特性
| 属性 | 说明 |
|---|---|
Xmlns |
(必需。用于此 [Content_Types].xml 文件的架构的位置。 |
{Attribute name} 特性
| 值 | 说明 |
|---|---|
http://schemas.openformats.org/package/2006/content-types |
内容类型架构的位置。 |
子元素
该 Types 元素可以包含任意数量的 Default 元素。
| 元素 | 说明 |
|---|---|
Default |
介绍 VSIX 包中的内容类型。 包中的每个文件类型都必须有自己的 Default 元素。 |
特性
| 属性 | 说明 |
|---|---|
Extension |
VSIX 包中文件的文件扩展名。 |
ContentType |
描述与文件扩展名关联的内容类型。 |
{Attribute name} 特性
Visual Studio 可识别关联Extension类型的以下ContentType值。
| 扩展 | ContentType |
|---|---|
| txt | text/plain |
| pkgdef | text/plain |
| xml | text/xml |
| vsixmanifest | text/xml |
| htm 或 html | text/html |
| rtf | application/rtf |
| application/pdf | |
| GIF | image/gif |
| jpg 或 jpeg | image/jpg |
| tiff | image/tiff |
| vsix | application/zip |
| zip | application/zip |
| dll | application/octet-stream |
| 所有其他文件类型 | application/octet-stream |
示例
说明
以下 [Content_Types].xml 文件描述了典型的 VSIX 包。
代码
<?xml version="1.0" encoding="utf-8" ?>
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
<Default Extension="vsixmanifest" ContentType="text/xml" />
<Default Extension="dll" ContentType="application/octet-stream" />
<Default Extension="png" ContentType="application/octet-stream" />
<Default Extension="txt" ContentType="text/plain" />
<Default Extension="pkgdef" ContentType="text/plain" />
</Types>