-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathStart-IsolatedProcess.ps1
38 lines (34 loc) · 1.15 KB
/
Start-IsolatedProcess.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
param (
[Parameter(Mandatory, Position = 0, ValueFromPipeline)]
[string]$ContainerName,
[Parameter(Mandatory, Position = 1, ValueFromPipeline)]
[string]$ApplicationName,
[Parameter(Position = 2, ValueFromPipeline)]
[string[]]$Arguments,
[Parameter(ValueFromPipeline)]
[switch]$ReleaseBuild,
[Parameter(ValueFromPipeline)]
[switch]$SkipBuild
)
$ErrorActionPreference = "Stop"
$exePath = ".\target\debug\run_app_container.exe"
$cargoArgs = @("build")
if ($ReleaseBuild) {
$cargoArgs += "--release"
$exePath = ".\target\release\run_app_container.exe"
}
if (!$SkipBuild -or !(Test-Path $exePath)) {
cargo $cargoArgs
}
$commandLine = "--container-name", $ContainerName, "--application-name", $ApplicationName
if ($VerbosePreference -eq [System.Management.Automation.ActionPreference]::Continue) {
$commandLine += "--debug", "--debug"
}
elseif ($DebugPreference -eq [System.Management.Automation.ActionPreference]::Continue) {
$commandLine += "--debug"
}
if ($Arguments.Count -ne 0) {
$commandLine += "--command-line"
$commandLine += $Arguments | ForEach-Object { $_.Replace("`"", "\`"") }
}
& $exePath $commandLine