Skip to content

Commit 67886c3

Browse files
committed
Import module with -Force and add -UseExistingBuild option to deploy.ps1
1 parent 8110572 commit 67886c3

File tree

4 files changed

+28
-12
lines changed

4 files changed

+28
-12
lines changed

deploy/build-ev2.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ param (
1818
)
1919

2020
dynamicparam {
21-
Import-Module (Join-Path $PSScriptRoot "scripts/NuGet.Insights.psm1")
21+
Import-Module (Join-Path $PSScriptRoot "scripts/NuGet.Insights.psm1") -Force
2222

2323
$ConfigNamesKey = "ConfigNames"
2424
$configNamesParameter = Get-ConfigNameDynamicParameter ([string[]]) $ConfigNamesKey

deploy/build-host.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ param (
88
[string]$OutputPath
99
)
1010

11-
Import-Module (Join-Path $PSScriptRoot "scripts/NuGet.Insights.psm1")
11+
Import-Module (Join-Path $PSScriptRoot "scripts/NuGet.Insights.psm1") -Force
1212
$RuntimeIdentifier = Get-DefaultRuntimeIdentifier $RuntimeIdentifier
1313

1414
$hostVersion = "4.27.1"

deploy/deploy.ps1

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

2528
dynamicparam {
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

4043
process {
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 = @{

deploy/prepare.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ param (
55
)
66

77
dynamicparam {
8-
Import-Module (Join-Path $PSScriptRoot "scripts/NuGet.Insights.psm1")
8+
Import-Module (Join-Path $PSScriptRoot "scripts/NuGet.Insights.psm1") -Force
99

1010
$ConfigNameKey = "ConfigName"
1111
$configNamesParameter = Get-ConfigNameDynamicParameter ([string[]]) $ConfigNameKey
@@ -20,7 +20,7 @@ begin {
2020
}
2121

2222
process {
23-
Import-Module (Join-Path $PSScriptRoot "scripts/NuGet.Insights.psm1")
23+
Import-Module (Join-Path $PSScriptRoot "scripts/NuGet.Insights.psm1") -Force
2424

2525
$runtimeIdentifier = Get-DefaultRuntimeIdentifier $null $false
2626
$resourceSettings = Get-ResourceSettings $ConfigName $StampName $runtimeIdentifier

0 commit comments

Comments
 (0)