我们希望为开发人员部署一些外部工具到Visual Studio。有没有办法通过脚本或类似方法自动化它或者是否所有这些都是手动完成的?
答案 0 :(得分:3)
对于Visual Studio 2013,外部工具在注册表中进行管理
HKEY_CURRENT_USER \ Software \ Microsoft \ VisualStudio \ 12.0 \ External Tools
您应该能够编写注册表脚本来添加所需内容。确保在任何更新之前备份注册表。
答案 1 :(得分:1)
有点晚了,但我在寻找同样的事情时偶然发现了这个问题,最后编写了一个识别新的可用工具编号的批处理文件。
将所需的VS版本设置为逗号分隔(适用于VS 2015 - 14.0,VS 2017使用私有注册表 - 请参阅this post),以及该文件开头的工具参数。
@echo off
echo.
rem ========================================
rem Configure desired Tool values and desired VS Versions (tested only for 14.0, other should be the same)
rem ========================================
set VSVersions=13.0,14.0
set ToolTitle=Abrir prompt testes front-end...
set ToolCmd=$(SolutionDir)\FrontendTestsPrepare.bat
set ToolDir=$(SolutionDir)
set ToolOpt=0x12
set ToolArg=
set ToolSourceKey=
rem ========================================
rem Logic begins
rem ========================================
for %%a in ("%VSVersions:,=" "%") do (
CALL:REGISTER_TOOL %%~a
)
exit /b
:REGISTER_TOOL
set VSToolRegKey=HKEY_CURRENT_USER\SOFTWARE\Microsoft\VisualStudio\%1\External Tools
echo Registering tool for VS %1
rem ========================================
rem Gets and sets tool count and new index
rem ========================================
CALL:GETTOOLCOUNT "%VSToolRegKey%"
set ToolCount=%ERRORLEVEL%
echo Tool Index: %ToolCount%
set NewToolIndex=%ToolCount%
set /a NewToolCount=%ToolCount%+1
rem ========================================
rem Update Tool Count
rem ========================================
reg add "%VSToolRegKey%" /v ToolNumKeys /f /t REG_DWORD /d 0x%NewToolCount%
rem ========================================
rem Creates
rem ========================================
reg add "%VSToolRegKey%" /v ToolTitle%NewToolIndex% /d "%ToolTitle%"
reg add "%VSToolRegKey%" /v ToolCmd%NewToolIndex% /d "%ToolCmd%"
reg add "%VSToolRegKey%" /v ToolDir%NewToolIndex% /d "%ToolDir%"
reg add "%VSToolRegKey%" /v ToolOpt%NewToolIndex% /d %ToolOpt% /t REG_DWORD
reg add "%VSToolRegKey%" /v ToolArg%NewToolIndex% /d "%ToolArg%"
reg add "%VSToolRegKey%" /v ToolSourceKey%NewToolIndex% /d "%ToolSourceKey%"
echo.
echo.
GOTO :EOF
:GETTOOLCOUNT
set ToolCount=0
set RegQueryOutput=
rem Tests if registry path exists, returning 1 if not
reg query %1 /f ToolNumKeys /v > nul 2>&1
IF NOT %ERRORLEVEL%==0 exit /b %ToolCount%
rem Gets tool count from reg query output
for /f "tokens=*" %%i in ('reg query %1 /f ToolNumKeys /v ^| findstr "0x.*"') do set RegQueryOutput=%%i
for /F "tokens=3 delims= " %%E in ("%RegQueryOutput%") do set ToolCount=%%E
set ToolCount=%ToolCount:0x=%
exit /b %ToolCount%
可以在“ToolOpt”中一起使用的标志如下(摘自here):
#define TOOLOPT_ISAPPGUI 0x01
#define TOOLOPT_CLOSEONEXIT 0x02
#define TOOLOPT_PROMPTFORARGS 0x04
#define TOOLOPT_USEOUTPUTWIN 0x08
#define TOOLOPT_SAVEALLDOCS 0x10
#define TOOLOPT_USETASKLIST 0x20
#define TOOLOPT_UNICODE 0x40