From e7c315b65cdb425065a442b8eaca378ea8a0cee8 Mon Sep 17 00:00:00 2001 From: Dan Thompson Date: Thu, 26 Jul 2018 10:30:05 -0700 Subject: [PATCH] `Start-DevPowerShell`: add `-Configuration` and handle `-ArgumentList` more properly (#7300) - Allow specifying the configuration, rather than the `bin` folder. - Do not attempt to pass null/empty `ArgumentList` to `Start-Process`. --- build.psm1 | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/build.psm1 b/build.psm1 index b8e59d4ecc..e590387da6 100644 --- a/build.psm1 +++ b/build.psm1 @@ -1858,16 +1858,25 @@ function Publish-NuGetFeed } function Start-DevPowerShell { + [CmdletBinding(DefaultParameterSetName='ConfigurationParamSet')] param( - [string[]]$ArgumentList = '', + [string[]]$ArgumentList = @(), [switch]$LoadProfile, - [string]$binDir = (Split-Path (New-PSOptions).Output), + [Parameter(ParameterSetName='ConfigurationParamSet')] + [ValidateSet("Debug", "Release", "CodeCoverage", '')] # should match New-PSOptions -Configuration values + [string]$Configuration, + [Parameter(ParameterSetName='BinDirParamSet')] + [string]$BinDir, [switch]$NoNewWindow, [string]$Command, [switch]$KeepPSModulePath ) try { + if (-not $BinDir) { + $BinDir = Split-Path (New-PSOptions -Configuration $Configuration).Output + } + if ((-not $NoNewWindow) -and ($Environment.IsCoreCLR)) { Write-Warning "Start-DevPowerShell -NoNewWindow is currently implied in PowerShellCore edition https://github.com/PowerShell/PowerShell/issues/1543" $NoNewWindow = $true @@ -1888,12 +1897,16 @@ function Start-DevPowerShell { $ArgumentList = $ArgumentList + @("-command $Command") } - $env:DEVPATH = $binDir + $env:DEVPATH = $BinDir + # splatting for the win $startProcessArgs = @{ - FilePath = "$binDir\pwsh" - ArgumentList = "$ArgumentList" + FilePath = "$BinDir\pwsh" + } + + if ($ArgumentList) { + $startProcessArgs.ArgumentList = $ArgumentList } if ($NoNewWindow) {