Skip to content

KsWare/KsWare.AppVeyorBuildTools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AppVeyorBuildTools

A set of cmdlets to use in AppVeyor CI.

How to use

1. Bootstrapper - getting cmdlets

(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.

2. run common initialization code (optional)

init:

- ps: Initialize-AppVeyor

Cmdlets

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

Import-AppVeyorModules will download und import all other AppVeyor cmdlets.

Initialize-AppVeyor

1. InitAppVeyorApiRequest

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"
    }

2. DetectPR

Initializes the $env:isPR variable

Update-VersionWithTimestamp

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

Update-Version

Publish-ToFTP

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

Reset-BuildNumber

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

Reset-NextBuildNumber

Resets the next build number to current build number (Reverts the auto-increment).

on_failure:
- ps: Reset-NextBuildNumber

Install-ClickOnceCerticate

Install-ClickOnceCerticate <cert-file> <password>
Install-ClickOnceCerticate mycert.pfx $env:CertPassword

Read-PublishProfile

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>

Environment Variables

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published