You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to have Developer Powershell for VS 2019 start when Hyper is launched, is that possible?
The startup script for the Developer Powershell is written below.
# C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\Launch-VsDevShell.ps1
[CmdletBinding(DefaultParameterSetName="Default")]
param (
[ValidateScript({Test-Path$_})]
[Parameter(ParameterSetName="VsInstallationPath")]
[string]
$VsInstallationPath="`"$($MyInvocation.MyCommand.Definition)`"",
[Parameter(ParameterSetName="Latest")]
[switch]
$Latest,
[Parameter(ParameterSetName="List")]
[switch]
$List,
[Parameter(ParameterSetName="List")]
[object[]]
$DisplayProperties=@("displayName","instanceId","installationVersion","isPrerelease","installationName","installDate"),
[Parameter(ParameterSetName="VsInstanceId",Mandatory=$true)]
[string]
$VsInstanceId,
[Parameter(ParameterSetName="Latest")]
[Parameter(ParameterSetName="List")]
[switch]
$ExcludePrerelease,
[ValidateScript({Test-Path$_-PathType 'Leaf'})]
[Parameter(ParameterSetName="Default")]
[Parameter(ParameterSetName="VsInstallationPath")]
[Parameter(ParameterSetName="Latest")]
[Parameter(ParameterSetName="List")]
[Parameter(ParameterSetName="VsInstanceId")]
[string]
$VsWherePath="`"${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe`""
)
functionGetSetupConfigurations {
param (
$whereArgs
)
Invoke-Expression"& $VsWherePath$whereArgs -format json"|ConvertFrom-Json
}
functionLaunchDevShell {
param (
$config
)
$basePath=$config.installationPath$instanceId=$config.instanceId$currModulePath="$basePath\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"# Prior to 16.3 the DevShell module was in a different location$prevModulePath="$basePath\Common7\Tools\vsdevshell\Microsoft.VisualStudio.DevShell.dll"$modulePath=if (Test-Path$prevModulePath) { $prevModulePath } else { $currModulePath }
if (Test-Path$modulePath) {
Write-Verbose"Found at $modulePath."try {
Import-Module$modulePath
}
catch [System.IO.FileLoadException] {
Write-Verbose"The module has already been imported from a different installation of Visual Studio:"
(Get-Module Microsoft.VisualStudio.DevShell).Path |Write-Verbose
}
$params=@{
VsInstanceId=$instanceId
}
# -ReportNewInstanceType is only available from 16.5if ((Get-CommandEnter-VsDevShell).Parameters["ReportNewInstanceType"]) {
$params.ReportNewInstanceType="LaunchScript"
}
Enter-VsDevShell@paramsexit
}
throw [System.Management.Automation.ErrorRecord]::new(
[System.Exception]::new("Required assembly could not be located. This most likely indicates an installation error. Try repairing your Visual Studio installation. Expected location: $modulePath"),"DevShellModuleLoad",
[System.Management.Automation.ErrorCategory]::NotInstalled,$config)
}
functionVsInstallationPath {
$args="-path $VsInstallationPath"Write-Verbose"Using path: $VsInstallationPath"$config= GetSetupConfigurations($args)
LaunchDevShell($config)
}
functionLatest {
$args="-latest"if (-not$ExcludePrerelease) {
$args+=" -prerelease"
}
$config= GetSetupConfigurations($args)
LaunchDevShell($config)
}
functionVsInstanceId {
$configs= GetSetupConfigurations("-prerelease -all")
$config=$configs|Where-Object { $_.instanceId-eq$VsInstanceId }
if ($config) {
Write-Verbose"Found Visual Studio installation with InstanceId of '$($config.instanceId)' and InstallationPath '$($config.installationPath)'"
LaunchDevShell($config)
exit
}
throw [System.Management.Automation.ErrorRecord]::new(
[System.Exception]::new("Could not find an installation of Visual Studio with InstanceId '$VsInstanceId'."),"VsSetupInstance",
[System.Management.Automation.ErrorCategory]::InvalidArgument,$config)
}
functionList {
$args="-sort"if (-not$ExcludePrerelease) {
$args=" -prerelease"
}
$configs= GetSetupConfigurations($args)
$DisplayProperties=@("#") +$DisplayProperties# Add an incrementing select column$configs=$configs|Sort-Object displayName, installationDate |ForEach-Object { $i=0 } { $i++; $_|Add-Member-NotePropertyName "#"-NotePropertyValue $i-PassThru }
Write-Host"The following Visual Studio installations were found:"$configs|Format-Table-Property $DisplayProperties$selected=Read-Host"Enter '#' of the Visual Studio installation to launch DevShell. <Enter> to quit: "if (-not$selected) { exit }
$config=$configs|Where-Object { $_."#"-eq$selected }
if ($config) {
LaunchDevShell($config)
}
else {
"Invalid selection: $selected"
}
}
functionDefault{
Write-Verbose"No parameters passed to script. Trying VsInstallationPath."try {
VsInstallationPath
exit
}
catch {
Write-Verbose"VsInstallationPath failed. Trying Latest."
}
Write-Host"Could not start Developer PowerShell using the script path."Write-Host"Attempting to launch from the latest Visual Studio installation."try {
Latest
exit
}
catch {
Write-Verbose"Latest failed. Defaulting to List."
}
Write-Host"Could not start Developer PowerShell from the latest Visual Studio installation."Write-Host
List
}
if ($PSCmdlet.ParameterSetName) {
& (Get-ChildItem"Function:$($PSCmdlet.ParameterSetName)")
exit
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I would like to have Developer Powershell for VS 2019 start when Hyper is launched, is that possible?
The startup script for the Developer Powershell is written below.
Beta Was this translation helpful? Give feedback.
All reactions