安装时如何自动启用 VSIX 扩展? [英] How can I automatically enable a VSIX extension, when installing?

查看:28
本文介绍了安装时如何自动启用 VSIX 扩展?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个 VSIX 包,我通过 WIX 生成的 MSI 安装该包.

I've created a VSIX package that I install via a WIX-generated MSI.

但是,当我安装它并在 VS2010 中查看时,在工具 > 扩展管理器 菜单中,它是[禁用],我需要启用它手动.

However, when I install it, and look at it in VS2010, in the Tools > Extension Manager menu, it is [Disabled] and I need to enable it manually.

我怎样才能避免这种情况?

How can I avoid this?

** 编辑 **
这是我所做的:
我尝试像这样从注册表中添加捕获 VSInstallDir:

** EDIT **
Here's what I did:
I tried adding capturing the VSInstallDir from the registry like this:

    <Property Id="VSINSTALLER">
  <RegistrySearch Id="VSInstallRegistry" Root="HKLM" Key="SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0" Name="InstallDir"  Type="directory" />

我在target-dir下添加了这样的目录结构:

I added the directory structure under target-dir like this:

    <Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="VSINSTALLER">
    <Directory Id="Extensions" Name="Extensions">
      <Directory Id="Copy_CompanyFolder" Name="my company">
        <Directory Id="INSTALLVSIX" Name="app name">
        </Directory>
      </Directory>
    </Directory>
  </Directory>

并且我在安装文件夹中的组件中添加了一个 CopyFile 元素,如下所示:

And I added a CopyFile element to the component in the installation folder, like this:

            <Component Id="VsPackage" Guid="00000000-0000-some-guid-00000000">
          <File Id="VsPackageInstaller" Source="$(folder.prop)\extensionName.vsix"
                KeyPath="yes" DiskId="1">
            <CopyFile Id="Copy_InstallVsix"
                      DestinationDirectory="INSTALLVSIX" />
          </File>
        </Component>

我在清单中添加了 true 元素.

And I added the true element to the manifest.

当我这样做时,扩展程序安装.

When I do this, the extension is not installed.

知道为什么吗?

推荐答案

如果您将扩展文件安装到您在 %VSInstallDir%\Common7\IDE\Extensions 下创建的目录中,它将自动为所有用户启用.这是对 MSI 安装的扩展程序的建议.

If you install your extension files to a directory you create under %VSInstallDir%\Common7\IDE\Extensions, it will be enabled automatically for all users. This is the recommendation for MSI-installed extensions.

另外,请务必将 true 添加到您的 vsixmanifest.

Also, please be sure to add <InstalledByMsi>true</InstalledByMsi> to your vsixmanifest.

无需运行 VSIXInstaller.exe 或编写注册表项来启用您的扩展(事实上,您真的不应该这样做.).

There is no need to run VSIXInstaller.exe or write registry keys to enable your extension (In fact, you really shouldn't do this.).

这篇关于安装时如何自动启用 VSIX 扩展?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆