Skip to content

Commit

Permalink
Run Unpackaged Unit Tests with winget-installed PsExec (#4760)
Browse files Browse the repository at this point in the history
Currently forked builds do not have the permission to access secure
files.

To workaround using PsExec from a secure file, we will use a stable
release of winget to install the latest PsTools and try invoking unit
tests from the PsExec executable that is installed as part of the zip
package.
  • Loading branch information
ryfu-msft authored Aug 29, 2024
1 parent 269c3c6 commit 32cee15
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -348,18 +348,30 @@ jobs:
inputs:
packageFeedSelector: 'nugetOrg'

- task: DownloadSecureFile@1
name: PsExec
displayName: 'Download PsExec.exe'
inputs:
secureFile: 'PsExec.exe'
# TODO: Repair-WinGetPackageManager will fail because it tries to install x64 for an x86 build machine.
# Remove manual installation of VCLibs (x64) once this is fixed.
- powershell: |
if ("$(buildPlatform)" -eq "x86") {
iwr https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx -OutFile Microsoft.VCLibs.x64.appx

Check failure on line 355 in azure-pipelines.yml

View workflow job for this annotation

GitHub Actions / Check Spelling

`iwr` is not a recognized word. (unrecognized-spelling)
Add-AppxPackage Microsoft.VCLibs.x64.appx
}
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Install-Module Microsoft.WinGet.Client -Repository PSGallery -Force
Repair-WingetPackageManager -AllUsers -Latest
Install-WinGetPackage -Id Microsoft.Sysinternals.PsTools -Source winget
displayName: Install Sysinternals PsTools Using Winget
condition: succeededOrFailed()
- task: CmdLine@2
- powershell: |
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
PsExec -accepteula -s -i $(buildOutDir)\AppInstallerCLITests\AppInstallerCLITests.exe -logto $(artifactsDir)\AICLI-Unpackaged-System.log -s -r junit -o $(artifactsDir)\TEST-AppInstallerCLI-Unpackaged-System.xml
displayName: Run Unit Tests Unpackaged Under System Context
inputs:
script: |
$(PsExec.secureFilePath) -accepteula -s -i $(buildOutDir)\AppInstallerCLITests\AppInstallerCLITests.exe -logto $(artifactsDir)\AICLI-Unpackaged-System.log -s -r junit -o $(artifactsDir)\TEST-AppInstallerCLI-Unpackaged-System.xml
workingDirectory: '$(buildOutDir)\AppInstallerCLITests'
workingDirectory: '$(buildOutDir)\AppInstallerCLITests'
condition: succeededOrFailed()
- powershell: |
Uninstall-WinGetPackage -Id Microsoft.Sysinternals.PsTools -Source winget
displayName: Clean up Sysinternals PsTools
condition: succeededOrFailed()
- task: PowerShell@2
Expand Down

0 comments on commit 32cee15

Please sign in to comment.