-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy.ps1
More file actions
53 lines (46 loc) · 1.48 KB
/
Copy pathdeploy.ps1
File metadata and controls
53 lines (46 loc) · 1.48 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
param(
[string]$Configuration = 'Release',
[string]$PublishProfile = 'Properties/PublishProfiles/WinClickOnce.pubxml',
[switch]$RegisterClickOnce
)
$ErrorActionPreference = 'Stop'
$root = Split-Path -Parent $MyInvocation.MyCommand.Path
Set-Location $root
function Invoke-Step {
param (
[string]$Message,
[scriptblock]$Action
)
Write-Host "[deploy] $Message" -ForegroundColor Cyan
& $Action
if (-not $?) {
throw "Step failed: $Message"
}
}
Invoke-Step 'Building project' {
dotnet build -c $Configuration
}
$now = Get-Date
$buildComponent = "{0:yyMM}" -f $now
$instrumentedRevision = (($now.Day - 1) * 1440) + ($now.Hour * 60) + $now.Minute
$appVersion = "1.0.$buildComponent.0"
Invoke-Step 'Publishing ClickOnce installer via MSBuild' {
.\Publish-Installer.ps1 `
-Configuration $Configuration `
-PublishProfile $PublishProfile `
-ApplicationVersion $appVersion `
-ApplicationRevision $instrumentedRevision
}
$publishDir = Join-Path $root "bin\$Configuration\net9.0-windows\publish"
$installHelper = Join-Path $root 'Install-ClickOnce.ps1'
if (Test-Path $installHelper) {
Copy-Item -Path $installHelper -Destination (Join-Path $publishDir 'Install-ClickOnce.ps1') -Force
}
Invoke-Step 'Staging install and refreshing shortcuts' {
if ($RegisterClickOnce) {
& $installHelper -SourcePath $publishDir -RegisterClickOnce
}
else {
& $installHelper -SourcePath $publishDir
}
}