Compare commits

...

1 Commits

Author SHA1 Message Date
Leilei Zhang
9bd0e32382 add install step 2025-07-31 16:34:45 +08:00
3 changed files with 124 additions and 6 deletions

View File

@@ -0,0 +1,72 @@
param(
[string]$Architecture = "x64"
)
# Check if Git is installed
function Test-GitInstalled {
try {
git --version > $null 2>&1
return $true
}
catch {
return $false
}
}
# Install Git
function Install-Git {
Write-Host "##[section]Installing Git for Windows ($Architecture)..."
$gitInstallerUrl = if ($Architecture.ToLower() -eq "arm64") {
"https://github.com/git-for-windows/git/releases/latest/download/Git-2.50.1-arm64.exe"
} else {
"https://github.com/git-for-windows/git/releases/latest/download/Git-2.50.1-64-bit.exe"
}
$installerPath = "$env:TEMP\GitInstaller.exe"
try {
Write-Host "##[command]Downloading Git installer..."
Invoke-WebRequest -Uri $gitInstallerUrl -OutFile $installerPath -UseBasicParsing
Write-Host "##[command]Installing Git silently..."
Start-Process -FilePath $installerPath -ArgumentList "/VERYSILENT", "/NORESTART" -Wait
# Clean up
Remove-Item $installerPath -Force -ErrorAction SilentlyContinue
# Refresh PATH
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
return $true
}
catch {
Write-Host "##[error]Failed to install Git: $($_.Exception.Message)"
return $false
}
}
# Main logic
Write-Host "##[section]Checking Git installation..."
if (Test-GitInstalled) {
Write-Host "##[section]Git is already installed"
} else {
Write-Host "##[warning]Git not found, installing..."
if (Install-Git) {
Start-Sleep -Seconds 3
if (Test-GitInstalled) {
Write-Host "##[section]Git installation successful"
} else {
Write-Host "##[error]Git installation failed"
exit 1
}
} else {
Write-Host "##[error]Failed to install Git"
exit 1
}
}
Write-Host "##[section]Git setup completed successfully"

View File

@@ -109,12 +109,9 @@ jobs:
sdk: true
version: '9.0'
- task: VisualStudioTestPlatformInstaller@1
displayName: Ensure VSTest Platform
- pwsh: |-
& '$(build.sourcesdirectory)\.pipelines\InstallWinAppDriver.ps1'
displayName: Download and install WinAppDriver
- template: steps-install-test-dependencies.yml
parameters:
platform: ${{ parameters.platform }}
- ${{ if not(variables.isBuildNow) }}:
- task: DownloadPipelineArtifact@2

View File

@@ -0,0 +1,49 @@
parameters:
- name: platform
type: string
default: "x64"
steps:
- task: NuGetToolInstaller@1
displayName: Install NuGet Tool
- task: NuGetCommand@2
displayName: Install Microsoft.UI.Xaml 2.8.7
inputs:
command: 'custom'
arguments: 'install Microsoft.UI.Xaml -Version 2.8.7 -OutputDirectory $(Agent.TempDirectory)\packages -NonInteractive'
- powershell: |-
$arch = if ('${{ parameters.platform }}' -eq 'ARM64') { 'arm64' } else { 'x64' }
& '$(build.sourcesdirectory)\.pipelines\EnsureGitInstalled.ps1' -Architecture $arch
displayName: "Ensure Git is installed"
- pwsh: |-
# Check if winget is available
try {
winget --version > $null 2>&1
Write-Host "##[section]Winget is already installed"
}
catch {
Write-Host "##[section]Installing Winget..."
# Download and install App Installer (which includes winget)
$wingetUrl = "https://aka.ms/getwinget"
$installerPath = "$env:TEMP\Microsoft.DesktopAppInstaller.msixbundle"
Invoke-WebRequest -Uri $wingetUrl -OutFile $installerPath -UseBasicParsing
Add-AppxPackage -Path $installerPath
# Clean up
Remove-Item $installerPath -Force -ErrorAction SilentlyContinue
Write-Host "##[section]Winget installation completed"
}
displayName: "Ensure Winget is installed"
- task: VisualStudioTestPlatformInstaller@1
displayName: Ensure VSTest Platform
- powershell: |-
& '$(build.sourcesdirectory)\.pipelines\InstallWinAppDriver.ps1'
displayName: Download and install WinAppDriver