winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

Run-LocalhostWebServer.ps1 (1982B)


      1 <#
      2 .SYNOPSIS
      3     Runs the LocalhostWebServer.
      4 .PARAMETER BuildRoot
      5     The root of the build output directory for LocalhostWebServer
      6 .PARAMETER StaticFileRoot
      7     The root of the static files to be served through Localhost
      8 .PARAMETER CertPath
      9     Path to HTTPS Development Certificate File (pfx)
     10 .PARAMETER CertPassword
     11     Secure Password for HTTPS Certificate
     12 .PARAMETER OutCertFile
     13     Export cert location.
     14 .PARAMETER LocalSourceJson
     15     Local source json definition
     16 .PARAMETER SourceCert
     17     The certificate of the source package.
     18 #>
     19 
     20 param(
     21     [Parameter(Mandatory=$true)]
     22     [string]$BuildRoot,
     23 
     24     [Parameter(Mandatory=$true)]
     25     [string]$StaticFileRoot,
     26 
     27     [Parameter(Mandatory=$true)]
     28     [string]$CertPath,
     29 
     30     [Parameter()]
     31     [string]$CertPassword,
     32 
     33     [Parameter()]
     34     [string]$OutCertFile,
     35 
     36     [Parameter()]
     37     [string]$LocalSourceJson,
     38 
     39     [Parameter()]
     40     [string]$SourceCert,
     41 
     42     [Parameter()]
     43     [string]$TestDataPath,
     44 
     45     [Parameter()]
     46     [switch]$ExitBeforeRun
     47 )
     48 
     49 if (-not [System.String]::IsNullOrEmpty($sourceCert))
     50 {
     51     # Requires admin
     52     & certutil.exe -addstore -f "TRUSTEDPEOPLE" $sourceCert
     53 }
     54 
     55 Push-Location $BuildRoot
     56 
     57 $startProcessArguments = @{
     58     FilePath = Join-Path $BuildRoot "LocalhostWebServer.exe"
     59     ArgumentList = "StaticFileRoot=$StaticFileRoot CertPath=$CertPath CertPassword=$CertPassword OutCertFile=$OutCertFile LocalSourceJson=$LocalSourceJson TestDataPath=$TestDataPath ExitBeforeRun=$ExitBeforeRun"
     60     PassThru = $true
     61 }
     62 
     63 if (-not [System.string]::IsNullOrEmpty($env:artifactsDir))
     64 {
     65     $startProcessArguments.RedirectStandardOutput = Join-Path $env:artifactsDir "LocalhostWebServer.out"
     66     $startProcessArguments.RedirectStandardError = Join-Path $env:artifactsDir "LocalhostWebServer.err"
     67 }
     68 
     69 $Local:process = Start-Process @startProcessArguments
     70 
     71 if ($ExitBeforeRun)
     72 {
     73     Wait-Process -InputObject $Local:process
     74 }
     75 
     76 Pop-Location