-
Notifications
You must be signed in to change notification settings - Fork 827
Expand file tree
/
Copy pathappveyor.yml
More file actions
124 lines (97 loc) · 5.99 KB
/
Copy pathappveyor.yml
File metadata and controls
124 lines (97 loc) · 5.99 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
image: Visual Studio 2022
configuration: Release
platform: x64
install:
- git submodule update --init
- ps: |
Invoke-WebRequest -Uri 'https://dot.net/v1/dotnet-install.ps1' -UseBasicParsing -OutFile "$env:temp\dotnet-install.ps1"
# 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
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).
$Architectures = @(
@{ RuntimeIdentifier = "win-x64"; Platform = "x64" },
@{ RuntimeIdentifier = "win-arm64"; Platform = "ARM64" }
)
foreach ($Architecture in $Architectures) {
Write-Host "Building $($Architecture.RuntimeIdentifier)..."
dotnet build "$($env:APPVEYOR_BUILD_FOLDER)\Source\NETworkManager.Setup\NETworkManager.Setup.wixproj" `
--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-windows10.0.22621.0\$($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"
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