Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Win av2 #51

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions appveyor-build-win-agent-v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
environment:
matrix:

# GCE
# =======

- job_name: Bake image with Agent v2
APPVEYOR_BUILD_WORKER_IMAGE: vs2019-master-gce-us-central1
APPVEYOR_BAKE_IMAGE: win-agentv2

AGENT_VERSION: 7.0.2879
AGENT_INSTALL_DIR: '%ProgramFiles%\AppVeyor\BuildAgentCore'
BUILD_AGENT_MODE: GCE

init:
- appveyor version
- ps: $ErrorActionPreference = 'Stop'
- ps: $env:cloud_type = (Get-ItemProperty "HKLM:\Software\AppVeyor\Build Agent").Mode
- ps: 'Write-Host "OS Build: $((Get-CimInstance Win32_OperatingSystem).BuildNumber)"'

clone_folder: '%USERPROFILE%\image-bake-scripts'

clone_script:
- ps: Invoke-WebRequest "https://github.com/appveyor/build-images/archive/$($env:APPVEYOR_REPO_COMMIT).zip" -OutFile "$env:temp\scripts.zip"
- ps: Expand-Archive -Path "$env:temp\scripts.zip" -DestinationPath "$env:temp\scripts" -Force
- ps: Copy-Item -Path "$env:temp\scripts\build-images-$($env:APPVEYOR_REPO_COMMIT)\scripts\Windows\*" -Destination $env:APPVEYOR_BUILD_FOLDER -Recurse

test: off

# on_failure:
# - ps: Get-EventLog AppVeyor -newest 10 | Format-List

build_script:
- ps: .\install_appveyor_build_agent_core.ps1
- ps: |
$appveyorPath = "$env:ProgramFiles\AppVeyor\BuildAgentCore"
$pwshProfileFilename = "$env:USERPROFILE\Documents\PowerShell\Microsoft.PowerShell_profile.ps1"

if (Test-Path $pwshProfileFilename) {
$lines = Get-Content $pwshProfileFilename
for($i = 0; $i -lt $lines.length; $i++) {
if ($lines[$i] -contains '*AppVeyor.BuildAgent.PowerShell.dll*') {
$lines[$i] = ''
}
}
$lines += "try { Import-Module '$appveyorPath\AppVeyor.BuildAgent.PowerShell.dll' } catch {}"
$lines | Set-Content $pwshProfileFilename
}
11 changes: 11 additions & 0 deletions scripts/Windows/install_appveyor_build_agent_core.ps1
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
$AGENT_VERSION = '7.0.2417'

if ($env:AGENT_VERSION) {
$AGENT_VERSION = $env:AGENT_VERSION
}

Write-Host "Installing AppVeyor Build Agent Core"
Write-Host "===================================="

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

$destPath = "$env:ProgramFiles\AppVeyor\BuildAgent"

if ($env:AGENT_INSTALL_DIR) {
$destPath = $env:AGENT_INSTALL_DIR
}

Write-Host "Installing Build Agent Core version $AGENT_VERSION to '$destPath'"

if (Test-Path $destPath) {
Remove-Item $destPath -Recurse -Force
}
Expand All @@ -28,6 +38,7 @@ New-Item "HKLM:\Software\AppVeyor" -Name "BuildAgent" -Force | Out-Null
if ($env:appveyor_url) {$appVeyorUrl = $env:appveyor_url} else {$appVeyorUrl = 'https://ci.appveyor.com'}
Set-ItemProperty "HKLM:\Software\AppVeyor\BuildAgent" -Name "AppVeyorUrl" -Value appVeyorUrl
Set-ItemProperty "HKLM:\Software\AppVeyor\BuildAgent" -Name "Mode" -Value $env:BUILD_AGENT_MODE
Set-ItemProperty "HKLM:\Software\AppVeyor\BuildAgent" -Name "ProjectBuildsDirectory" -Value ""

# Enable auto load on system start
New-Item "HKCU:\Software\Microsoft\Windows\CurrentVersion" -Name "Run" -Force | Out-Null
Expand Down
2 changes: 1 addition & 1 deletion scripts/Windows/install_powershell_core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if (Test-Path $appveyorPath) {

if (-not (Test-Path $pwshProfileFilename) -or (Get-Content $pwshProfileFilename | Where-Object { $_.Contains("AppVeyor.BuildAgent.PowerShell.dll") }).Count -eq 0) {
Write-Host "Updating $pwshProfileFilename with AppVeyor PS Modules"
Add-Content $pwshProfileFilename "`nImport-Module '$appveyorPath\dotnetcore\AppVeyor.BuildAgent.PowerShell.dll'"
Add-Content $pwshProfileFilename "`ntry { Import-Module '$appveyorPath\dotnetcore\AppVeyor.BuildAgent.PowerShell.dll' } catch {}"
} else {
Write-Host "Import of AppVeyor Modules already exists in $pwshProfileFilename"
}
Expand Down