pkgdef设计理念(翻译)

What's A PkgDef? And Why? - Visual Studio Blog (microsoft.com)

.pkgdef file is way to encapsulate application configuration information in an easily editable, distributable, and deployable form. It was introduced in Visual Studio 2008 SP1 to support the configuration of Isolated Shell applications. In Visual Studio 2010, .pkgdef files take on a more expanded role and are much more integrated into both the IDE and the Shell (Integrated and Isolated). This article will briefly describe the .pkgdef format and introduce the scenarios where it is used in VS 2010. Future posts will go into more detail about particular scenarios.

pkgdef文件用一种易于编辑、分发、部署的应用程序配置文件。它是在Visual Studio 2008 SP1中引入的,以支持对独立的Shell应用程序的配置。在Visual Studio 2010中,.pkgdef文件扮演了一个更加扩展的角色,并且更完整的集成到IDE和Shell中(集成和隔离)。本文将简要描述.pkgdef格式,并介绍它在VS 2010中使用的场景。接下来的文章将对特定场景进行更详细的介绍。

Here is a portion of a .pkgdef file that registers the Extension Manager (which is written as a VS Package) with the IDE:

下面是.pkgdef文件的一部分,它向IDE注册了扩展管理器(它是一个VS包):

It looks a lot like a .reg file as exported from the Registry Editor. There is one key difference: the root of the registry key (e.g., “HKEY_LOCAL_MACHINESoftwareMicrosoftVisualStudio10.0”) has been abstracted into the token “$RootKey$”. This, and several other tokenized values for registry keys and paths, allows a given .pkgdef file to be reusable for multiple applications and portable to any machine.

这和从注册表编辑器导出的.reg文件很像。有一个关键的区别:注册表项的根(“HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio10.0”)在pkgdef中被抽象为“$RootKey$”。没有注册表项的标记性路径的值,使得.pkgdef文件相对而言可用于多个应用程序并可移植到任何机器。

This example also demonstrates why this format was originally called a “pkgdef”. A .pkgdef file can be used to define the registration of a package. Now that this format is used for many other registration and configuration tasks, there was some talk of changing the name and extension to something more generic. We decided that the pkgdef appellation was just as good as anything else. Like most computer terminology, the first name seems to have stuck.

这个例子也说明了为什么这个格式最初被称为“pkgdef”(Package define)它可以用来定义包的注册。这种格式现在用于许多其他注册和配置任务,有人说将名称和扩展更改为更通用的东西。我们认为pkgdef的称谓也很好。就像大多数计算机术语一样,第一个名字是固定不变的。

Let’s go back and look at that first application of the .pkgdef file to configure Isolated Shell applications in VS 2008 and see what it involved. An Isolated Shell application reads its configuration data from at least four .pkgdef files.

让我们回过头来看看在VS 2008中配置的第一个隔离Shell应用程序的pkgdef文件,看看它涉及到什么。一个独立Shell应用程序从至少四个.pkgdef文件中读取配置数据。.


MyVSShellStub.pkgdef

在创建独立Shell应用程序项目时,由“新建项目向导”创建。主pkgdef负责配置应用程序的pkgdef环境。

MyVSShellStub.exe在同一目录

MyVSShellStub.Application.pkgdef

也由向导创建。包含用于配置和标记隔离应用程序的基本值

MyVSShellStub.exe的扩展文件夹下

MyVsShellStub.pkgundef

也由向导创建. 用于删除(或取消定义)被配置为隔离Shell可重新发布安装的一部分的包(参见BaseConfig.pkgdef)

MyVSShellStub.exe在同一目录

BaseConfig.pkgdef

part of the Isolated Shell redistributable installation. Contains configuration information for the core features of the Shell, such as the Editor and Designers and the other parts of the IDE

在C:Program Files Microsoft Visual Studio X.0 Common7 IDE下

MyPackage*.pkgdef

created for any VS Package projects that are created as part of the Isolated Shell application

MyVSShellStub.exe的扩展文件夹下 (也可能在由PkgDefSearchPath定义的其他地方)



Notice that that configuration and registration information originates from both the application developer and Microsoft. All of these values have to be merged into a common location specific to the application so that the Shell and the Packages in the application can retrieve them. In VS 2008, this was done during installation of the Isolated Shell application by running the application executable with the “/setup” switch (as a setup Custom Action). This caused the Shell to read all of the .pkgdef files and build a new configuration hive for the application in the registry under HKEY_LOCAL_MACHINE. During the development and test cycle of an Isolated Shell application, the “/ranu” (“run as normal user”) switch was used to create a test hive under HKEY_CURRENT_USER, in order to avoid issues with having Administrator access to the registry.

配置和注册信息可以来自应用程序开发人员也可以是Microsoft。所有这些值必须合并到特定于应用程序的公共位置,以便应用程序中的Shell和Packages可以检索到它们。

在vs2008中,这是在安装独立shell应用程序期间,通过运行应用程序可执行文件的“/setup”开关(作为一个设置自定义动作)完成的。这使得Shell读取所有的.pkgdef文件,并在注册表HKEY_LOCAL_MACHINE下为应用程序构建一个新的配置hive。如果是在应用程序的开发和测试周期中,“使用/ranu”(“作为普通用户运行”)开关会在HKEY_CURRENT_USER下创建一个测试hive,可以避免使用Administrator访问注册表的问题。

Visual Studio 2010 makes the .pkgdef load and merge operation a normal part of initialization sequence for both the Shell and the IDE. It also locates the target of the merge, known as the config (or configuration) cache, under HKEY_CURRENT_USER (next to the user settings for the application, but with a “_Config” suffix). This eliminates the need to run the merge as part of setup and eliminates the need for the “/ranu” switch during testing. It also enables an additional scenario: the Extension Manager.

Visual Studio 2010将.pkgdef加载和合并,作为Shell和IDE初始化序列的一部分。它还定位合并的目标,称为配置(或配置)缓存,在HKEY_CURRENT_USER下(在应用程序的用户设置旁边,并带有“_Config”后缀)。这消除了在设置过程中运行合并的需要,也消除了在测试过程中使用“/ranu”开关的需要。它还支持一个额外的场景:扩展管理器。

The Extension Manager feature allows users to download extensions to the Visual Studio IDE and integrate them without having to run setup. Extensions that are written as VS Packages that must register with the IDE do so using a .pkgdef file. Simply restarting the IDE after the extension is installed (by unzipping its VSIX file) and enabled causes the IDE to build a merged registry hive out of the values that were written to HKEY_LOCAL_MACHINE during Visual Studio setup and the values in .pkgdef files found on disk. The user is not required to take any extra steps or have Administrator privileges.

扩展管理器功能允许用户下载扩展到Visual Studio IDE上并集成它们,而无需运行安装程序。作为VS包编写的扩展,必须使用.pkgdef文件注册到IDE。在扩展被安装(通过解压缩它的VSIX文件)并启用后,简单地重新启动IDE,会导致IDE从Visual Studio安装期间写入HKEY_LOCAL_MACHINE的值和在磁盘上找到的.pkgdef文件中的值构建一个合并的注册表hive。用户不需要采取任何额外的步骤,也不需要拥有管理员权限。

You may notice that in the case of the Isolated Shell application all of the configuration values come from .pkgdef files. But in the case of the Visual Studio IDE some of the values come from HKEY_LOCAL_MACHINE. In the latter case, VS continues to use the HKLM hive in order to support some compatibility and servicing scenarios. But we plan to continue moving more configuration values out of the registry as we are able.

在独立应用程序的情况下,所有的配置值都来自于.pkgdef文件。但是在Visual Studio IDE的情况下,一些值来自HKEY_LOCAL_MACHINE。在后一种情况下,VS继续使用HKEY_LOCAL_MACHINE以支持一些兼容性和服务场景。但是我们计划继续将更多的配置值移出注册表。

The .pkgdef file was introduced in VS 2008 to allow a more modular way to deploy configuration values for the Visual Studio Shells. Improvements in .pkgdef file loading and merging in VS 2010 have made the use of .pkgdef files more automatic and enabled the setup-less installation of Visual Studio extensions.

pkgdef文件是在VS 2008中引入的,它允许以更模块化的方式部署Visual Studio shell的配置值。在VS 2010中,.pkgdef文件加载和合并的改进使.pkgdef文件的使用更加自动化,并使Visual Studio扩展的安装步骤更为简洁。

In future posts, I plan to describe in more detail how and when VS decides to refresh the config cache, why a .pkgdef file might not be loaded and how to debug that, and the purposes of the various .pkgdef files.

在以后的文章中,我计划更详细地描述VS如何以及何时决定刷新配置缓存,为什么。pkgdef文件可能不会被加载,以及如何调试它,以及各种。pkgdef文件的目的。

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 220,699评论 6 513
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 94,124评论 3 395
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 167,127评论 0 358
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 59,342评论 1 294
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 68,356评论 6 397
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 52,057评论 1 308
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,654评论 3 420
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,572评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 46,095评论 1 318
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 38,205评论 3 339
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 40,343评论 1 352
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 36,015评论 5 347
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,704评论 3 332
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 32,196评论 0 23
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,320评论 1 271
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,690评论 3 375
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 45,348评论 2 358

推荐阅读更多精彩内容