2017-07-26 59 views
1

有谁知道是否可以使用EnvDTE或任何其他方法将条目添加到Visual Studio 2017的“外部工具”菜单?到目前为止,我发现的唯一一件事是添加一些似乎不适用于VS2017的注册表项。以编程方式将条目添加到Visual Studio 2017的“外部工具”菜单中

+0

这是否意味着VS2017正在使用.. \ 14.0 \ External Tools中的密钥?我认为这个注册表分支只能被VS2015读取。 –

+0

我自己并没有掌握,但[这里](https://github.com/MicrosoftDocs/visualstudio-docs/blob/master/docs/extensibility/writing-to-the-user-settings-store.md)你可以找到一个如何访问“用户设置存储”的例子。看起来相当于我。 –

+0

Visual Studio 2017现在将其设置存储在一个私有注册表文件中,而不是在常用的Windows注册表中。看到这[相关文章](https://stackoverflow.com/questions/41119996/where-does-visual-studio-2017-rc-store-its-config) –

回答

2

回答我的问题...

在评论这个问题的自Axel肯珀环节终于把我带到这个SO answer这给出了一个非常简单的方法添加到外部工具列表中的条目。

基本上,您可以在IDE中生成所需的工具,并使用“工具|导入和导出设置”将相应的设置导出到xml文件。在我的情况下,我得到以下内容:

<UserSettings> 
    <ApplicationIdentity version="15.0"/> 
    <ToolsOptions/> 
    <Category name="Environment_Group" RegisteredName="Environment_Group"> 
    <Category name="Environment_ExternalTools" Category="{E8FAE9E8-FBA2-4474-B134-AB0FFCFB291D}" Package="{DA9FB551-C724-11d0-AE1F-00A0C90FFFC3}" RegisteredName="Environment_ExternalTools" PackageName="Visual Studio Environment Package"> 
     <ExternalTools> 
     <UserCreatedTool> 
      <Arguments>upload</Arguments> 
      <CloseOnExit>true</CloseOnExit> 
      <Command>c:\toolchain\make\make.exe</Command> 
      <InitialDirectory>$(ProjectDir)</InitialDirectory> 
      <IsGUIapp>false</IsGUIapp> 
      <NameID>0</NameID> 
      <Package>{00000000-0000-0000-0000-000000000000}</Package> 
      <PromptForArguments>false</PromptForArguments> 
      <SaveAllDocs>true</SaveAllDocs> 
      <Title>neuteensy</Title> 
      <Unicode>false</Unicode> 
      <UseOutputWindow>true</UseOutputWindow> 
      <UseTaskList>false</UseTaskList> 
     </UserCreatedTool> 
     </ExternalTools> 
    </Category> 
    </Category> 
</UserSettings> 

如有必要,很容易手动或以编程方式调整文件中的设置。

您可以将文件传递给用户进行手动导入,也可以使用envDTE自动导入该文件,如链接答案中所示。

+0

这工作。按照描述导出工具设置,编辑XML以删除除导入选项以外的所有选项(因为默认情况下会导出工具列表中的所有条目)。然后使用DTE导入。其他详细信息在这里:https://stackoverflow.com/a/34328236/3063884 – CJBS

1

作为替代,我写了下面的cmd.exe脚本加载和访问的Visual Studio 2017年的私人注册表:

@echo off 
:: 
:: vsExtTools.cmd - Script to list external tools of Visual Studio 2017 
:: 
:: Axel Kemper 29-Jul-2017 1st draft 
:: 
setlocal 

set VS_VERSION=15.0 
set VS_APP_ROOT=%localappdata%\Microsoft 
set DEBUG=1 
set DEBUG=0 

:: The RootSuffix for a normal VS installation will be blank. 
:: This is mostly used for the experimental instance 
:: cf https://blog.agchapman.com/updating-registry-settings-for-visual-studio-2017/ 
set ROOT_SUFFIX= 

call :findVSInstance %VS_APP_ROOT%\VisualStudio\%VS_VERSION% %ROOT_SUFFIX% 
set REG_FILE=%VS_INSTANCE%\privateregistry.bin 
if not exist "%REG_FILE%" goto no_reg 

set HIVE_ROOT=HKLM\vsHive 
call :trace Temporary registry hive %HIVE_ROOT% 

:: administrative privileges are needed to load a hive 
call :checkAdminRights 
if [%IS_ADMIN%]==[0] goto xit 

call :trace Loading registry hive from %REG_FILE% 
reg.exe load %HIVE_ROOT% "%REG_FILE%" 

call :trace %HIVE_ROOT% 
reg.exe QUERY "%HIVE_ROOT%\Software\Microsoft\VisualStudio\%VS_HIVE%\External Tools" /s 

:: Then you can use reg.exe to manipulate the hive 

call :trace Unloading registry hive 
reg.exe unload %HIVE_ROOT% 

goto xit 

:: ==================================================================== 
:findVSInstance 
set VS_INSTANCE= 
for /D %%D in (%1_*%2) do set VS_INSTANCE=%%D 
for /D %%D in (%1_*%2) do set VS_HIVE=%%~nxD 
call :trace VS Instance %VS_INSTANCE% 
call :trace VS Hive %VS_HIVE% 
goto :EOF 

:: ==================================================================== 
:checkAdminRights 
set IS_ADMIN=1 
AT > NUL 
IF %ERRORLEVEL% EQU 0 goto gotAdmin 

call :grumble This script requires administrative privileges! 
set IS_ADMIN=0 
:gotAdmin 
goto :EOF 

:: ==================================================================== 
:grumble 
echo. 
echo %* 
echo. 
goto :EOF 

:: ==================================================================== 
:no_reg 
call :grumble Visual Studio %VS_VERSION% instance directory not found! 
goto :xit 

:: ==================================================================== 
:trace 
if [%DEBUG%]==[1] (
echo %* 
) 
goto :EOF 

:: ==================================================================== 
:xit 
endlocal 
pause 

此版本需要管理员权限,只是列出了External Tool设置。可以添加对reg.exe的调用以创建新的工具设置条目。

相关问题