e2e-setup.yml (2778B)
1 # Configures local test source and local PowerShell repository. 2 parameters: 3 - name: sourceDir 4 type: string 5 - name: localhostWebServerArgs 6 type: string 7 - name: signingCertOutDir 8 type: string 9 default: $(Agent.TempDirectory) 10 11 steps: 12 - pwsh: | 13 $newCertArguments = @{ 14 Type = "Custom" 15 Subject = "CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" 16 KeyUsage = "DigitalSignature" 17 TextExtension = @("2.5.29.37={text}1.3.6.1.5.5.7.3.3", "2.5.29.19={text}") 18 CertStoreLocation = "Cert:\CurrentUser\My" 19 } 20 $cert = New-SelfSignedCertificate @newCertArguments 21 22 $certPfxPath = Join-Path $(Agent.TempDirectory) TestSigningCert.pfx 23 $certCerPath = Join-Path ${{ parameters.signingCertOutDir }} TestSigningCert.cer 24 $certPassword = (New-Guid).ToString() 25 $certSecurePassword = ConvertTo-SecureString $certPassword -AsPlainText 26 27 Export-PfxCertificate -Cert $cert -FilePath $certPfxPath -Password $certSecurePassword 28 Export-Certificate -Cert $cert -FilePath $certCerPath 29 30 Write-Host "##vso[task.setvariable variable=TestSigningCert.PfxPath;]$certPfxPath" 31 Write-Host "##vso[task.setvariable variable=TestSigningCert.CerPath;]$certCerPath" 32 Write-Host "##vso[task.setvariable variable=TestSigningCert.Password;]$certPassword" 33 displayName: Create test codesigning cert 34 condition: succeededOrFailed() 35 36 - pwsh: | 37 $httpsCertPath = Join-Path $(Agent.TempDirectory) HttpsCert.pfx 38 $httpsCertPassword = (New-Guid).ToString() 39 dotnet dev-certs https --export-path $httpsCertPath --password $httpsCertPassword 40 41 $securePassword = ConvertTo-SecureString $httpsCertPassword -AsPlainText 42 Import-PfxCertificate -FilePath $httpsCertPath -Password $securePassword -CertStoreLocation Cert:\LocalMachine\Root 43 44 Write-Host "##vso[task.setvariable variable=HttpsCert.Path;]$httpsCertPath" 45 Write-Host "##vso[task.setvariable variable=HttpsCert.Password;]$httpsCertPassword" 46 displayName: Create and install localhost HTTPS cert 47 condition: succeededOrFailed() 48 49 - pwsh: ${{ parameters.sourceDir }}\src\LocalhostWebServer\Run-LocalhostWebServer.ps1 -CertPath $(HttpsCert.Path) -CertPassword $(HttpsCert.Password) -OutCertFile $(Agent.TempDirectory)\servercert.cer ${{ parameters.localhostWebServerArgs }} 50 displayName: Launch LocalhostWebServer 51 condition: succeededOrFailed() 52 53 - task: PowerShell@2 54 displayName: Setup Local PS Repository 55 condition: succeededOrFailed() 56 inputs: 57 filePath: '${{ parameters.sourceDir }}\src\AppInstallerCLIE2ETests\TestData\Configuration\Init-TestRepository.ps1' 58 arguments: '-Force' 59 pwsh: true