Repository navigation
Expand file tree
/
Copy pathappveyor.yml
More file actions
203 lines (162 loc) · 9.94 KB
/
Copy pathappveyor.yml
File metadata and controls
203 lines (162 loc) · 9.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
image: Visual Studio 2022
# Also exported as CONFIGURATION / PLATFORM environment variables, which MSBuild reads as properties.
configuration: Release
platform: x64
environment:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_GENERATE_ASPNET_CERTIFICATE: false
# Shallow clone - the history isn't needed (the version is date based). Must stay > 1, the docs-only check below
# compares HEAD with HEAD~1.
clone_depth: 50
# Branch builds only for main and release tags (e.g. 2026.10.24.0 - the filter also applies to tag names). Other
# branches are only built as PR (merge commit), Mergify waits for that status. skip_branch_with_pr is not enough, the
# first push of a branch (e.g. by Dependabot) is built before the PR exists. PRs to main are not affected by "only".
branches:
only:
- main
- /^\d+\.\d+\.\d+/
install:
- ps: |
# Skip the build if only docs / website / repository files changed. Exit-AppveyorBuild ends the build
# successfully, so a green status is still reported (Mergify waits for it). Tag (release) builds are never
# skipped. PR builds check out the merge commit (HEAD~1 = target branch), so this is the full PR diff.
# Branch builds only see the last commit of a push, so they are only skipped for squash merges of a PR
# (subject ends with "(#1234)") - the PR build already checked the full diff. Direct pushes are always built.
# If git diff fails, the build runs normally.
$IsPullRequest = [bool]$env:APPVEYOR_PULL_REQUEST_NUMBER
$IsSquashMerge = (git log -1 --format=%s HEAD) -match '\(#\d+\)$'
if ($env:APPVEYOR_REPO_TAG -ne "true" -and ($IsPullRequest -or $IsSquashMerge)) {
# --no-renames: a moved file is listed with its old and new path (a file moved out of Source/ is build relevant)
$ChangedFiles = git diff --name-only --no-renames HEAD~1 HEAD 2>$null
if ($LASTEXITCODE -eq 0 -and $ChangedFiles) {
$BuildRelevantFiles = $ChangedFiles | Where-Object { $_ -notmatch '^(Website/|\.github/|\.claude/|Images/|Chocolatey/|WinGet/|Tests/Environments/|LICENSE$)|\.md$' }
if (-not $BuildRelevantFiles) {
Write-Host "Only docs / website / repository files changed - skipping build."
Exit-AppveyorBuild
return
}
Write-Host "Build relevant changes:"
$BuildRelevantFiles | ForEach-Object { Write-Host " $_" }
}
}
- git submodule update --init
- ps: |
# Read the required SDK version from global.json instead of hardcoding it, so Dependabot's
# weekly SDK bumps there don't silently drift out of sync with what CI installs.
$DotnetVersion = (Get-Content "$($env:APPVEYOR_BUILD_FOLDER)\Source\global.json" -Raw | ConvertFrom-Json).sdk.version
# Skip the download if the build image already has this SDK.
if (dotnet --list-sdks | Where-Object { $_ -like "$DotnetVersion *" }) {
Write-Host ".NET SDK $DotnetVersion (from Source\global.json) is already installed"
return
}
Invoke-WebRequest -Uri 'https://dot.net/v1/dotnet-install.ps1' -UseBasicParsing -OutFile "$env:temp\dotnet-install.ps1"
Write-Host "Installing .NET SDK $DotnetVersion (from Source\global.json)"
& $env:temp\dotnet-install.ps1 -Architecture x64 -Version $DotnetVersion -InstallDir "$env:ProgramFiles\dotnet"
before_build:
- dotnet restore %APPVEYOR_BUILD_FOLDER%\Source\NETworkManager.sln
- ps: |
# Set the version based on the current date (e.g. 2024.4.27.0)
$Date = Get-Date
$VersionString = $Date.ToString("yyyy.M.d.0")
Write-Host "Set NETworkManager version set to $VersionString"
# Update assembly version
$AssemblyVersionPattern = '\[assembly: AssemblyVersion\("(.*)"\)\]'
$AssemblyFileVersionPattern = '\[assembly: AssemblyFileVersion\("(.*)"\)\]'
$AssemblyFile = "$($env:APPVEYOR_BUILD_FOLDER)\Source\GlobalAssemblyInfo.cs"
$AssemlbyContent = Get-Content -Path $AssemblyFile -Encoding utf8
$AssemlbyContent = $AssemlbyContent -replace $AssemblyVersionPattern, "[assembly: AssemblyVersion(""$($VersionString)"")]"
$AssemlbyContent = $AssemlbyContent -replace $AssemblyFileVersionPattern, "[assembly: AssemblyFileVersion(""$($VersionString)"")]"
$AssemlbyContent | Set-Content -Path $AssemblyFile -Encoding utf8
# Set setup version information
$SetupVersionString = $Date.ToString("yy.M.d") # MSI only supports major.minor.build and 255 as highest value
Write-Host "Set NETworkManager setup version set to $SetupVersionString"
$SetupVersionPattern = '<\?define ProductVersion="(.*)" \?>'
$SetupFile = ".\Source\NETworkManager.Setup\Package.wxs"
$SetupContent = Get-Content -Path "$SetupFile" -Encoding utf8
$SetupContent = $SetupContent -replace $SetupVersionPattern, "<?define ProductVersion=""$SetupVersionString"" ?>"
$SetupContent | Set-Content -Path "$SetupFile" -Encoding utf8
build_script:
- ps: |
# Build the wixproj directly, not the .sln - `dotnet build` rejects -p:RuntimeIdentifier
# at the solution level (NETSDK1134). PRs only build the application, unless they change the setup (e.g. WiX
# updates via Dependabot) - the setup is always built on branches and tags.
$Project = "$($env:APPVEYOR_BUILD_FOLDER)\Source\NETworkManager.Setup\NETworkManager.Setup.wixproj"
if ($env:APPVEYOR_PULL_REQUEST_NUMBER) {
# PR builds check out the merge commit (HEAD~1 = target branch), so this is the full PR diff
$ChangedFiles = git diff --name-only --no-renames HEAD~1 HEAD 2>$null
if ($LASTEXITCODE -eq 0 -and -not ($ChangedFiles | Where-Object { $_ -like "Source/NETworkManager.Setup/*" })) {
$Project = "$($env:APPVEYOR_BUILD_FOLDER)\Source\NETworkManager\NETworkManager.csproj"
}
}
Write-Host "Building $Project"
$Architectures = @(
@{ RuntimeIdentifier = "win-x64"; Platform = "x64" }
)
# Only tags (release) are built for ARM64 - branches and PRs are built for x64 to keep them fast.
if ($env:APPVEYOR_REPO_TAG -eq "true") {
$Architectures += @{ RuntimeIdentifier = "win-arm64"; Platform = "ARM64" }
}
foreach ($Architecture in $Architectures) {
Write-Host "Building $($Architecture.RuntimeIdentifier)..."
dotnet build "$Project" `
--configuration Release --no-restore `
-p:Platform=$($Architecture.Platform) -p:RuntimeIdentifier=$($Architecture.RuntimeIdentifier) -p:PlatformTarget=$($Architecture.Platform)
if ($LASTEXITCODE -ne 0) {
throw "dotnet build failed for $($Architecture.RuntimeIdentifier) with exit code $LASTEXITCODE"
}
}
after_build:
- ps: |
$ErrorActionPreference = "Stop"
if($env:APPVEYOR_REPO_TAG -eq $false) {
Write-Host "Release build is skipped because no tag was found!"
return
}
$ArtifactsPath = "$($env:APPVEYOR_BUILD_FOLDER)\Artifacts"
# Create release folder
New-Item -Path "$ArtifactsPath" -ItemType Directory -Force | Out-Null
# Architectures to package. RuntimeIdentifier is appended to every file name (e.g. _win-x64, _win-arm64).
$Architectures = @(
@{ RuntimeIdentifier = "win-x64"; SetupPlatform = "x64" },
@{ RuntimeIdentifier = "win-arm64"; SetupPlatform = "ARM64" }
)
foreach ($Architecture in $Architectures) {
# Build path - includes the Platform segment because NETworkManager.csproj now inherits
# -p:Platform from the wixproj build, and MSBuild folds a non-AnyCPU Platform into OutputPath.
$BuildPath = "$($env:APPVEYOR_BUILD_FOLDER)\Source\NETworkManager\bin\$($Architecture.SetupPlatform)\Release\net10.0-windows\$($Architecture.RuntimeIdentifier)"
$SetupPath = "$($env:APPVEYOR_BUILD_FOLDER)\Source\NETworkManager.Setup\bin\$($Architecture.SetupPlatform)\Release\en-US\NETworkManager.Setup.msi"
# Get version
$Version = [System.Diagnostics.FileVersionInfo]::GetVersionInfo("$($BuildPath)\NETworkManager.exe").FileVersion
# Cleanup build
Get-ChildItem -Path "$BuildPath" -Recurse | Where-Object { $_.Name.EndsWith(".pdb") } | Remove-Item
Remove-Item -Path "$($BuildPath)\WebView2Loader.dll"
# Create archive
Compress-Archive -Path "$($BuildPath)\*" -DestinationPath "$($ArtifactsPath)\NETworkManager_$($Version)_Archive_$($Architecture.RuntimeIdentifier).zip"
# Create portable
New-Item -Path "$BuildPath" -Name "IsPortable.settings" -ItemType File | Out-Null
Compress-Archive -Path "$($BuildPath)\*" -DestinationPath "$($ArtifactsPath)\NETworkManager_$($Version)_Portable_$($Architecture.RuntimeIdentifier).zip"
Remove-Item -Path "$($BuildPath)\IsPortable.settings"
# Copy setup
Move-Item -Path "$SetupPath" -Destination "$($ArtifactsPath)\NETworkManager_$($Version)_Setup_$($Architecture.RuntimeIdentifier).msi"
}
# Create artifacts archive for signing
Compress-Archive -Path "$ArtifactsPath\*" -DestinationPath "$($ArtifactsPath).zip"
test_script:
- ps: |
# Run from Source - dotnet test only picks up Source\global.json (Microsoft.Testing.Platform, which needs --project
# instead of a positional path) from the working directory. Otherwise it falls back to VSTest (MSB1001: Unknown switch).
Set-Location "$($env:APPVEYOR_BUILD_FOLDER)\Source"
dotnet test --project "NETworkManager.Tests\NETworkManager.Tests.csproj" --configuration Release --no-restore
if ($LASTEXITCODE -ne 0) {
throw "dotnet test failed with exit code $LASTEXITCODE"
}
artifacts:
- path: 'Artifacts.zip'
deploy:
- provider: Webhook
url: https://app.signpath.io/API/v1/0a191750-608c-457a-a11d-8a5433ad6491/Integrations/AppVeyor?ProjectSlug=NETworkManager&SigningPolicySlug=release-signing&ArtifactConfigurationSlug=artifacts
authorization:
secure: PF6YBkp3Gg4c9TUX4HOzgjG5FeCzq9hYMCG5Zbs6xEL3jVuWe605D+Q/x1PKtK/q2nxUGzQIvOdiWbXMnUXWQg==
on:
APPVEYOR_REPO_TAG: true