|
| 1 | +<# |
| 2 | +.SYNOPSIS |
| 3 | +Run this PowerShell script to enable dev mode and/or a custom script for the TypeScript language service, e.g. |
| 4 | +
|
| 5 | +PS C:\> .\scripts\VSDevMode.ps1 -enableDevMode -tsScript C:\src\TypeScript\built\local\typescriptServices.js |
| 6 | +
|
| 7 | +Note: If you get security errors, try running powershell as an Administrator and with the "-executionPolicy remoteSigned" switch |
| 8 | +
|
| 9 | +.PARAMETER vsVersion |
| 10 | +Set to "12" for Dev12 (VS2013) or "14" (the default) for Dev14 (VS2015) |
| 11 | +
|
| 12 | +.PARAMETER enableDevMode |
| 13 | +Pass this switch to enable attaching a debugger to the language service |
| 14 | +
|
| 15 | +.PARAMETER tsScript |
| 16 | +The path to a custom language service script to use, e.g. "C:\src\TypeScript\built\local\typescriptServices.js" |
| 17 | +#> |
| 18 | +Param( |
| 19 | + [int]$vsVersion = 14, |
| 20 | + [switch]$enableDevMode, |
| 21 | + [string]$tsScript |
| 22 | +) |
| 23 | + |
| 24 | +$vsRegKey = "HKCU:\Software\Microsoft\VisualStudio\${vsVersion}.0" |
| 25 | +$tsRegKey = "${vsRegKey}\TypeScriptLanguageService" |
| 26 | + |
| 27 | +if($enableDevMode -ne $true -and $tsScript -eq ""){ |
| 28 | + Throw "You must either enable language service debugging (-enableDevMode), set a custom script (-tsScript), or both" |
| 29 | +} |
| 30 | + |
| 31 | +if(!(Test-Path $vsRegKey)){ |
| 32 | + Throw "Visual Studio ${vsVersion} is not installed" |
| 33 | +} |
| 34 | +if(!(Test-Path $tsRegKey)){ |
| 35 | + # Create the TypeScript subkey if it doesn't exist |
| 36 | + New-Item -path $tsRegKey |
| 37 | +} |
| 38 | + |
| 39 | +if($tsScript -ne ""){ |
| 40 | + if(!(Test-Path $tsScript)){ |
| 41 | + Throw "Could not locate the TypeScript language service script at ${tsScript}" |
| 42 | + } |
| 43 | + Set-ItemProperty -path $tsRegKey -name CustomTypeScriptServicesFileLocation -value "${tsScript}" |
| 44 | + Write-Host "Enabled custom TypeScript language service at ${tsScript} for Dev${vsVersion}" |
| 45 | +} |
| 46 | +if($enableDevMode){ |
| 47 | + Set-ItemProperty -path $tsRegKey -name EnableDevMode -value 1 |
| 48 | + Write-Host "Enabled developer mode for Dev${vsVersion}" |
| 49 | +} |
0 commit comments