A set of cmdlets to use in AppVeyor CI.
(global-)appveyor.yml:
init:
- ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/KsWare/KsWare.AppVeyorBuildTools/develop/src/init.ps1'))
This will download and import all other useful cmdlets.
init:
…
- ps: Initialize-AppVeyor
…
Name | Description |
---|---|
Import-AppVeyorModules | |
Initialize-AppVeyor | |
Update-Version | |
Publish-ToFTP | |
Reset-BuildNumber | |
Reset-NextBuildNumber | Reset next build number to current build number |
Install-ClickOnceCerticate | |
Read-PublishProfile |
Import-AppVeyorModules will download und import all other AppVeyor cmdlets.
Initializes the $env:AppVeyorApiUrl
and $global:AppveyorApiRequestHeaders
variable
$global:AppVeyorApiUrl = 'https://ci.appveyor.com/api'
$global:AppveyorApiRequestHeaders = @{
"Authorization" = "Bearer $env:AppVeyorApiToken"
"Content-type" = "application/json"
"Accept" = "application/json"
}
Initializes the $env:isPR
variable
initializes $env:versionMeta
with current timestamp
updates AppVeyor and $env:APPVEYOR_BUILD_VERSION
Used to create unique numbers for each buid, so it s not needed to increment the build number if the build failed.
Use Reset-BuildNumber
in on_failure
script
Publishes all files from a directory to a ftp server
Publish-ToFTP <local-dir> <remote-dir> <username> <password>
Publish-ToFTP "MyProject\bin\publish" "ftp://server.name/path $env:FtpUser $env:FtpPassword
Resets the current build number to 0 and next build number to 1.
Used by Update-Version if the new version is greater then old version.
current: 1.2.3.444, new: 1.3.0 results in 1.3.0.0
Reset-BuildNumber
Resets the next build number to current build number (Reverts the auto-increment).
on_failure:
- ps: Reset-NextBuildNumber
Install-ClickOnceCerticate <cert-file> <password>
Install-ClickOnceCerticate mycert.pfx $env:CertPassword
Read-PublishProfile <profile-name>
Read-PublishProfile "ClickOnceProfile"
Result:
global:PublishProfileContent
The publish profile content [xml]
env:PublishDir
contains full path of <PublishDir>
env:PublishUrl
contains full path of <PublishUrl>
Name | Description | Example |
---|---|---|
env:isPR |
$true if current build is a pull request; else $false | |
env:BuildVersion |
"VersionPrefix" | 1.2.3 (from 1.2.3.999) |
env:BuildNumber |
Auto incremented build number | 999 |
env:VersionSuffix |
Version suffix | -pre or -beta |
env:VersionHasSuffix |
True False |
|
env:VersionMeta |
Version meta part, a timestamp | +20240805213940 |
env:NewBuildVersion |
new BuildVersion, read from file | 1.3.0 |
env:NewVersionSuffix |
new VersionSuffix, read from file | -alpha |
env:VersionFormat |
'Build version format' from AppVeyorSettings | 1.2.3.{build} |
env:NewVersionFormat |
new 'Build version format' | 1.3.0.{build} |
global:AppVeyorApiUrl |
https://ci.appveyor.com/api | |
global:AppveyorApiRequestHeaders |
@{ "Authorization" = "Bearer $env:AppVeyorApiToken" "Content-type" = "application/json" "Accept" = "application/json" } |
|
global:AppVeyorSettings |