Skip to content

Commit 32cee15

Browse files
authored
Run Unpackaged Unit Tests with winget-installed PsExec (#4760)
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.
1 parent 269c3c6 commit 32cee15

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

azure-pipelines.yml

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -348,18 +348,30 @@ jobs:
348348
inputs:
349349
packageFeedSelector: 'nugetOrg'
350350

351-
- task: DownloadSecureFile@1
352-
name: PsExec
353-
displayName: 'Download PsExec.exe'
354-
inputs:
355-
secureFile: 'PsExec.exe'
351+
# TODO: Repair-WinGetPackageManager will fail because it tries to install x64 for an x86 build machine.
352+
# Remove manual installation of VCLibs (x64) once this is fixed.
353+
- powershell: |
354+
if ("$(buildPlatform)" -eq "x86") {
355+
iwr https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx -OutFile Microsoft.VCLibs.x64.appx
356+
Add-AppxPackage Microsoft.VCLibs.x64.appx
357+
}
358+
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
359+
Install-Module Microsoft.WinGet.Client -Repository PSGallery -Force
360+
Repair-WingetPackageManager -AllUsers -Latest
361+
Install-WinGetPackage -Id Microsoft.Sysinternals.PsTools -Source winget
362+
displayName: Install Sysinternals PsTools Using Winget
363+
condition: succeededOrFailed()
356364
357-
- task: CmdLine@2
365+
- powershell: |
366+
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
367+
PsExec -accepteula -s -i $(buildOutDir)\AppInstallerCLITests\AppInstallerCLITests.exe -logto $(artifactsDir)\AICLI-Unpackaged-System.log -s -r junit -o $(artifactsDir)\TEST-AppInstallerCLI-Unpackaged-System.xml
358368
displayName: Run Unit Tests Unpackaged Under System Context
359-
inputs:
360-
script: |
361-
$(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
362-
workingDirectory: '$(buildOutDir)\AppInstallerCLITests'
369+
workingDirectory: '$(buildOutDir)\AppInstallerCLITests'
370+
condition: succeededOrFailed()
371+
372+
- powershell: |
373+
Uninstall-WinGetPackage -Id Microsoft.Sysinternals.PsTools -Source winget
374+
displayName: Clean up Sysinternals PsTools
363375
condition: succeededOrFailed()
364376
365377
- task: PowerShell@2

0 commit comments

Comments
 (0)