@@ -19,11 +19,14 @@ param (
19
19
[string ]$WorkerZipPath ,
20
20
21
21
[Parameter (Mandatory = $false )]
22
- [string ]$AzureFunctionsHostZipPath
22
+ [string ]$AzureFunctionsHostZipPath ,
23
+
24
+ [Parameter (Mandatory = $false )]
25
+ [switch ]$UseExistingBuild
23
26
)
24
27
25
28
dynamicparam {
26
- Import-Module (Join-Path $PSScriptRoot " scripts/NuGet.Insights.psm1" )
29
+ Import-Module (Join-Path $PSScriptRoot " scripts/NuGet.Insights.psm1" ) - Force
27
30
28
31
$ConfigNameKey = " ConfigName"
29
32
$configNameParameter = Get-ConfigNameDynamicParameter ([string ]) $ConfigNameKey
@@ -38,7 +41,7 @@ begin {
38
41
}
39
42
40
43
process {
41
- Import-Module (Join-Path $PSScriptRoot " scripts/NuGet.Insights.psm1" )
44
+ Import-Module (Join-Path $PSScriptRoot " scripts/NuGet.Insights.psm1" ) - Force
42
45
43
46
$RuntimeIdentifier = Get-DefaultRuntimeIdentifier $RuntimeIdentifier
44
47
$resourceSettings = Get-ResourceSettings $ConfigName $StampName $RuntimeIdentifier
@@ -71,6 +74,13 @@ process {
71
74
# Publish (build and package) the app code
72
75
$deploymentDir = [System.IO.Path ]::GetFullPath((Join-Path $PSScriptRoot " ../artifacts/deploy" ))
73
76
function Publish-Project ($ProjectName ) {
77
+ $zipPath = Join-Path $deploymentDir " $ProjectName .zip"
78
+ if ($UseExistingBuild -and (Test-Path $zipPath )) {
79
+ $age = [DateTimeOffset ]::UtcNow - (Get-Item $zipPath ).LastWriteTimeUtc
80
+ Write-Status " Using existing build of '$ProjectName ', last modified $ ( [int ]$age.TotalMinutes ) minutes ago."
81
+ return $zipPath
82
+ }
83
+
74
84
Write-Status " Publishing project '$ProjectName '..."
75
85
# Workaround: https://github.com/Azure/azure-functions-dotnet-worker/issues/1834
76
86
dotnet build (Join-Path $PSScriptRoot " ../src/$ProjectName " ) `
@@ -96,14 +106,13 @@ process {
96
106
throw " Failed to publish $ProjectName ."
97
107
}
98
108
99
- $zipPath = Join-Path $deploymentDir " $ProjectName .zip"
100
109
Write-Host " Zipping $ProjectName "
101
110
Compress-Archive - Path (Join-Path $publishDir " *" ) - DestinationPath $zipPath - Force
102
111
103
112
Write-Host " Cleaning publish directory for $ProjectName "
104
113
Remove-Item $publishDir - Recurse - Force
105
114
106
- return $zipPath.ToString ()
115
+ return $zipPath
107
116
}
108
117
109
118
if (! $WebsiteZipPath ) { $WebsiteZipPath = Publish-Project " Website" }
@@ -112,9 +121,16 @@ process {
112
121
if (! (Test-Path $deploymentDir )) { New-Item $deploymentDir - ItemType Directory | Out-Null }
113
122
Write-Status " Publishing Azure Functions Host..."
114
123
$AzureFunctionsHostZipPath = Join-Path $deploymentDir " AzureFunctionsHost.zip"
115
- . (Join-Path $PSScriptRoot " build-host.ps1" ) `
116
- - RuntimeIdentifier $RuntimeIdentifier `
117
- - OutputPath $AzureFunctionsHostZipPath
124
+
125
+ if ($UseExistingBuild -and (Test-Path $AzureFunctionsHostZipPath )) {
126
+ $age = [DateTimeOffset ]::UtcNow - (Get-Item $AzureFunctionsHostZipPath ).LastWriteTimeUtc
127
+ Write-Status " Using existing build of Azure Functions Host, last modified $ ( [int ]$age.TotalMinutes ) minutes ago."
128
+ }
129
+ else {
130
+ . (Join-Path $PSScriptRoot " build-host.ps1" ) `
131
+ - RuntimeIdentifier $RuntimeIdentifier `
132
+ - OutputPath $AzureFunctionsHostZipPath
133
+ }
118
134
}
119
135
120
136
$parameters = @ {
0 commit comments