[vcpkgInvokeCommandClean] Don't use -encodedCommand.

Instead, use -Command with the appropriate number of escaped quotes
(which ended up being 3)
This commit is contained in:
Alexander Karatarakis 2018-02-07 17:31:19 -08:00
parent 815e3caf55
commit 3aac3957ae

View File

@ -190,10 +190,10 @@ function vcpkgInvokeCommandClean()
Write-Verbose "Clean-Executing: ${executable} ${arguments}"
$scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition
$cleanEnvScript = "$scriptsDir\VcpkgPowershellUtils-ClearEnvironment.ps1"
$command = "& `"$cleanEnvScript`"; & `"$executable`" $arguments"
$bytes = [System.Text.Encoding]::Unicode.GetBytes($command)
$encodedCommand = [Convert]::ToBase64String($bytes)
$arg = "-NoProfile -ExecutionPolicy Bypass -encodedCommand $encodedCommand"
$tripleQuotes = "`"`"`""
$argumentsWithEscapedQuotes = $arguments -replace "`"", $tripleQuotes
$command = ". $tripleQuotes$cleanEnvScript$tripleQuotes; & $tripleQuotes$executable$tripleQuotes $argumentsWithEscapedQuotes"
$arg = "-NoProfile", "-ExecutionPolicy Bypass", "-command $command"
$process = Start-Process -FilePath powershell.exe -ArgumentList $arg -PassThru -NoNewWindow
Wait-Process -InputObject $process