VSIX 封裝的剖析Anatomy of a VSIX package

VSIX 封裝是一個包含一或多個 Visual Studio 延伸模組的 .vsix 檔案,以及 Visual Studio 用來分類及安裝延伸模組的中繼資料 A VSIX package is a .vsix file that contains one or more Visual Studio extensions, together with the metadata Visual Studio uses to classify and install the extensions. 該中繼資料包含在 VSIX 資訊清單和 [Content_Types] .xml 檔案中。That metadata is contained in the VSIX manifest and the [Content_Types].xml file. VSIX 封裝也可以包含一或多個 vsixlangpack 檔案,以提供當地語系化的設定文字,而且可能包含其他 VSIX 套件來安裝相依性。A VSIX package may also contain one or more Extension.vsixlangpack files to provide localized setup text, and may contain additional VSIX packages to install dependencies.

VSIX 封裝格式會遵循開放式封裝慣例的 (OPC) 標準。The VSIX package format follows the Open Packaging Conventions (OPC) standard. 封裝包含二進位檔和支援檔案,以及 [Content_Types] .xml 檔案和 .vsix 資訊清單檔。The package contains binaries and supporting files, together with a [Content_Types].xml file and a .vsix manifest file. 一個 VSIX 封裝可能包含多個專案的輸出,或甚至是多個具有自己的資訊清單的封裝。One VSIX package may contain the output of multiple projects, or even multiple packages that have their own manifests.

注意

VSIX 套件中包含的檔案名不能包含空格,也不能在統一資源識別項中保留的字元 (URI) ,如 [ RFC2396 ] 中所定義。The names of the files included in VSIX packages must not include spaces, nor characters that are reserved in Uniform Resource Identifiers (URI), as defined under [RFC2396].

VSIX 資訊清單The VSIX manifest

VSIX 資訊清單包含要安裝之延伸模組的相關資訊,並遵循 VSX 架構。The VSIX manifest contains information about the extension to be installed, and follows the VSX Schema. 如需詳細資訊,請參閱 VSIX 延伸架構1.0 參考For more information, see VSIX extension schema 1.0 reference. 如需 VSIX 資訊清單的範例,請參閱 PackageManifest 元素 (根項目、VSX 架構) For an example VSIX manifest, see PackageManifest element (root element, VSX schema).

VSIX 資訊清單 extension.vsixmanifest 包含在 ^ * 檔案中時,必須命名為。The VSIX manifest must be named extension.vsixmanifest when it is included in a ^.vsix* file.

內容The content

VSIX 封裝可能包含範本、工具箱專案、Vspackage,或 Visual Studio 所支援的任何其他延伸模組類型。A VSIX package may contain templates, toolbox items, VSPackages, or any other kind of extension that is supported by Visual Studio.

語言套件Language packs

VSIX 封裝可包含一或多個 vsixlangpack 檔案,以便在安裝期間提供當地語系化文字。A VSIX package may contain once or more Extension.vsixlangpack files to provide localized text during installation. 如需詳細資訊,請參閱 當地語系化 VSIX 套件For more information, see Localizing VSIX packages.

相依性和參考Dependencies and references

VSIX 封裝可能包含其他 VSIX 封裝作為參考。A VSIX package may contain other VSIX packages as references. 這些其他封裝都必須包含自己的 VSIX 資訊清單。Each of these other packages must include its own VSIX manifest.

如果使用者嘗試安裝具有相依性的擴充功能,安裝程式會驗證是否已在使用者系統上安裝必要的元件。If a user tries to install an extension that has dependencies, the installer verifies that the required assemblies are installed on the user system. 如果找不到必要的元件,[ 擴充功能和更新 ] 會顯示遺漏的元件清單。If the required assemblies are not found, Extensions and Updates displays a list of the missing assemblies.

如果延伸模組資訊清單包含一或多個 參考 專案, 擴充功能和更新 會比較每個參考的資訊清單與系統上安裝的擴充功能,如果尚未安裝,則會安裝參考的擴充功能。If the extension manifest includes one or more Reference elements, Extensions and Updates compares the manifest of each reference to the extensions that are installed on the system, and installs the referenced extension if it is not already installed. 如果已安裝較舊版本的參考延伸模組,則較新的版本會取代它。If an earlier version of a referenced extension is installed, the newer version replaces it.

如果多專案方案中的專案包含相同方案中另一個專案的參考,則 VSIX 封裝會包含該專案的相依性。If a project in a multi-project solution includes a reference to another project in the same solution, the VSIX package includes the dependencies of that project. 您可以藉由選取內部專案的參考,然後在 [ 屬性 ] 視窗中,將 [VSIX] 屬性 中所含的輸出群組 設定為,來覆寫此行為 BuiltProjectOutputGroupYou can override this behavior by selecting the reference for the internal project, and then, in the Properties window, setting the Output Groups Included in VSIX property to BuiltProjectOutputGroup.

若要在 VSIX 封裝中包含參考元件的附屬 Dll,請加入 SatelliteDllsProjectOutputGroup vsix 屬性中 包含的輸出群組To include satellite DLLs from referenced assemblies in the VSIX package, add SatelliteDllsProjectOutputGroup to the Output Groups Included in VSIX property.

安裝位置Installation location

在安裝期間, 擴充功能和更新 會在 %LocalAppData%\Microsoft\VisualStudio\14.0\Extensions 下的資料夾中尋找 VSIX 封裝的內容。During installation, Extensions and Updates looks for the contents of the VSIX package in a folder under %LocalAppData%\Microsoft\VisualStudio\14.0\Extensions.

根據預設,安裝只會套用至目前的使用者,因為 % LocalAppData% 是使用者特定的目錄。By default, the installation applies only to the current user, because %LocalAppData% is a user-specific directory. 但是,如果您將資訊清單的AllUsers元素設定為 True ,此延伸模組會安裝在 \ 底下。VisualStudioInstallationFolder\Common7\IDE\Extensions將可供電腦的所有使用者使用。However, if you set the AllUsers element of the manifest to True, the extension will be installed under ..\VisualStudioInstallationFolder\Common7\IDE\Extensions and will be available to all users of the computer.

[Content_Types] .xml[Content_Types].xml

[Content_Types] .xml 檔案會識別擴充的 .vsix 檔中的檔案類型。The [Content_Types].xml file identifies the file types in the expanded .vsix file. Visual Studio 在套件安裝期間使用此檔案,但不會安裝檔案本身。Visual Studio uses this file during installation of the package but does not install the file itself. 如需此檔案的詳細資訊,請參閱 [Content_types] .xml檔案的結構。For more information about this file, see The structure of the [Content_types].xml file.

開放式封裝慣例 (OPC) standard 需要 [Content_Types] .xml 檔案。A [Content_Types].xml file is required by the Open Packaging Conventions (OPC) standard. 如需 OPC 的詳細資訊,請參閱 opc:將資料封裝 在 MSDN 網站的新標準。For more information about OPC, see OPC: A new standard for packaging your data on the MSDN Web site.