@@ -19,11 +19,14 @@ param (
1919 [string ]$WorkerZipPath ,
2020
2121 [Parameter (Mandatory = $false )]
22- [string ]$AzureFunctionsHostZipPath
22+ [string ]$AzureFunctionsHostZipPath ,
23+
24+ [Parameter (Mandatory = $false )]
25+ [switch ]$UseExistingBuild
2326)
2427
2528dynamicparam {
26- Import-Module (Join-Path $PSScriptRoot " scripts/NuGet.Insights.psm1" )
29+ Import-Module (Join-Path $PSScriptRoot " scripts/NuGet.Insights.psm1" ) - Force
2730
2831 $ConfigNameKey = " ConfigName"
2932 $configNameParameter = Get-ConfigNameDynamicParameter ([string ]) $ConfigNameKey
@@ -38,7 +41,7 @@ begin {
3841}
3942
4043process {
41- Import-Module (Join-Path $PSScriptRoot " scripts/NuGet.Insights.psm1" )
44+ Import-Module (Join-Path $PSScriptRoot " scripts/NuGet.Insights.psm1" ) - Force
4245
4346 $RuntimeIdentifier = Get-DefaultRuntimeIdentifier $RuntimeIdentifier
4447 $resourceSettings = Get-ResourceSettings $ConfigName $StampName $RuntimeIdentifier
@@ -71,6 +74,13 @@ process {
7174 # Publish (build and package) the app code
7275 $deploymentDir = [System.IO.Path ]::GetFullPath((Join-Path $PSScriptRoot " ../artifacts/deploy" ))
7376 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+
7484 Write-Status " Publishing project '$ProjectName '..."
7585 # Workaround: https://github.com/Azure/azure-functions-dotnet-worker/issues/1834
7686 dotnet build (Join-Path $PSScriptRoot " ../src/$ProjectName " ) `
@@ -96,14 +106,13 @@ process {
96106 throw " Failed to publish $ProjectName ."
97107 }
98108
99- $zipPath = Join-Path $deploymentDir " $ProjectName .zip"
100109 Write-Host " Zipping $ProjectName "
101110 Compress-Archive - Path (Join-Path $publishDir " *" ) - DestinationPath $zipPath - Force
102111
103112 Write-Host " Cleaning publish directory for $ProjectName "
104113 Remove-Item $publishDir - Recurse - Force
105114
106- return $zipPath.ToString ()
115+ return $zipPath
107116 }
108117
109118 if (! $WebsiteZipPath ) { $WebsiteZipPath = Publish-Project " Website" }
@@ -112,9 +121,16 @@ process {
112121 if (! (Test-Path $deploymentDir )) { New-Item $deploymentDir - ItemType Directory | Out-Null }
113122 Write-Status " Publishing Azure Functions Host..."
114123 $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+ }
118134 }
119135
120136 $parameters = @ {
0 commit comments