1
1
param (
2
- [string ]$buildNumber = " 0" ,
2
+ [string ]$buildNumber = " 0" ,
3
3
[string ]$suffix = " " ,
4
4
[ValidateSet (" 6" , " 8" , " " )][string ]$minorVersionPrefix = " " ,
5
5
[string ]$hashesForHardlinksFile = " hashesForHardlinks.txt"
6
6
)
7
7
8
+ Import-Module " $PSScriptRoot \Get-AzureFunctionsVersion.psm1" - Force
8
9
$rootDir = Split-Path - Parent $PSScriptRoot
9
- $buildOutput = Join-Path $rootDir " buildoutput"
10
+ $outDir = " $rootDir \out"
11
+ $publishDir = " $outDir \pub\WebJobs.Script.WebHost"
10
12
11
- Import-Module $PSScriptRoot \Get-AzureFunctionsVersion - Force
12
13
$extensionVersion = Get-AzureFunctionsVersion $buildNumber $suffix $minorVersionPrefix
13
14
Write-Host " Site extension version: $extensionVersion "
14
15
@@ -19,49 +20,44 @@ $patchVersion = [int]$versionParts[2]
19
20
$isPatch = $patchVersion -gt 0
20
21
Write-Host " MajorMinorVersion is '$majorMinorVersion '. Patch version is '$patchVersion '. IsPatch: '$isPatch '"
21
22
22
- function ZipContent ([string ] $sourceDirectory , [string ] $target )
23
- {
23
+ function ZipContent ([string ] $sourceDirectory , [string ] $target ) {
24
24
$stopwatch = [System.Diagnostics.Stopwatch ]::StartNew()
25
-
25
+
26
26
Write-Host " ======================================"
27
27
Write-Host " Zipping $sourceDirectory into $target "
28
-
28
+
29
29
if (Test-Path $target ) {
30
30
Remove-Item $target
31
31
}
32
+
32
33
Add-Type - assembly " system.io.compression.filesystem"
33
34
[IO.Compression.ZipFile ]::CreateFromDirectory($sourceDirectory , $target )
34
-
35
+
35
36
Write-Host " Done zipping $target . Elapsed: $ ( $stopwatch.Elapsed ) "
36
37
Write-Host " ======================================"
37
38
Write-Host " "
38
39
}
39
40
40
41
function BuildRuntime ([string ] $targetRid , [bool ] $isSelfContained ) {
41
42
$stopwatch = [System.Diagnostics.Stopwatch ]::StartNew()
42
- $runtimeSuffix = " .$targetRid "
43
- $ridSwitch = " "
44
-
45
- $publishTarget = " $buildOutput \publish\$targetRid "
46
- $symbolsTarget = " $buildOutput \symbols\$targetRid "
47
43
48
- $projectPath = " $PSScriptRoot \..\src\WebJobs.Script.WebHost\WebJobs.Script.WebHost.csproj"
44
+ $publishTarget = " $publishDir \release_$targetRid "
45
+ $projectPath = " $rootDir \src\WebJobs.Script.WebHost\WebJobs.Script.WebHost.csproj"
49
46
if (-not (Test-Path $projectPath ))
50
47
{
51
48
throw " Project path '$projectPath ' does not exist."
52
49
}
53
50
54
- $cmd = " publish" , " $PSScriptRoot \..\src\WebJobs.Script.WebHost\WebJobs.Script.WebHost.csproj " , " -r" , " $targetRid " , " --self-contained" , " $isSelfContained " , " -o " , " $publishTarget " , " -v " , " m " , " /p:BuildNumber= $buildNumber " , " /p:IsPackable=false " , " / p:MinorVersionPrefix=$minorVersionPrefix " , " -c " , " Release " , $suffixCmd
51
+ $cmd = " publish" , $projectPath , " -r" , " $targetRid " , " --self-contained" , " $isSelfContained " , " -v " , " m " , " -c " , " Release " , " -p:IsPackable=false " , " -p:BuildNumber= $buildNumber " , " - p:MinorVersionPrefix=$minorVersionPrefix "
55
52
56
53
Write-Host " ======================================"
57
54
Write-Host " Building $targetRid "
58
55
Write-Host " Self-Contained: $isSelfContained "
59
- Write-Host " Output Directory: $publishTarget "
60
- Write-Host " Symbols Directory: $symbolsTarget "
56
+ Write-Host " Publish Directory: $publishTarget "
61
57
Write-Host " "
62
58
Write-Host " dotnet $cmd "
63
59
Write-Host " "
64
-
60
+
65
61
& dotnet $cmd
66
62
67
63
if ($LASTEXITCODE -ne 0 )
@@ -70,20 +66,23 @@ function BuildRuntime([string] $targetRid, [bool] $isSelfContained) {
70
66
}
71
67
72
68
Write-Host " "
73
- Write-Host " Moving symbols to $symbolsTarget "
74
- New-Item - Itemtype directory - path $symbolsTarget - Force > $null
75
- Move-Item - Path $publishTarget \* .pdb - Destination $symbolsTarget - Force > $null
76
- Write-Host " "
77
- CleanOutput " $publishTarget "
69
+ $symbols = Get-ChildItem - Path $publishTarget - Filter * .pdb
70
+ Write-Host " Zipping symbols: $ ( $symbols.Count ) symbols found"
71
+
72
+ $symbolsPath = " $publishDir \Symbols"
73
+ if (! (Test-Path - PathType Container $symbolsPath )) {
74
+ New-Item - ItemType Directory - Path $symbolsPath | Out-Null
75
+ }
76
+
77
+ $symbols | Compress-Archive - DestinationPath " $symbolsPath \Functions.Symbols.$extensionVersion .$targetRid .zip" | Out-Null
78
+ $symbols | Remove-Item | Out-Null
79
+
80
+ Write-Host " "
81
+ CleanOutput $publishTarget
78
82
Write-Host " "
79
83
Write-Host " Done building $targetRid . Elapsed: $ ( $stopwatch.Elapsed ) "
80
84
Write-Host " ======================================"
81
85
Write-Host " "
82
-
83
- $zipOutput = " $buildOutput \Symbols"
84
- New-Item - Itemtype directory - path $zipOutput - Force > $null
85
-
86
- ZipContent $symbolsTarget " $zipOutput \Functions.Symbols.$extensionVersion$runtimeSuffix .zip"
87
86
}
88
87
89
88
function GetFolderSizeInMb ([string ] $rootPath ) {
@@ -93,11 +92,11 @@ function GetFolderSizeInMb([string] $rootPath) {
93
92
function CleanOutput ([string ] $rootPath ) {
94
93
Write-Host " Cleaning build output under $rootPath "
95
94
Write-Host " Current size: $ ( GetFolderSizeInMb $rootPath ) Mb"
96
-
95
+
97
96
Write-Host " Removing any linux and osx runtimes"
98
97
Remove-Item - Recurse - Force " $privateSiteExtensionPath \$bitness \runtimes\linux" - ErrorAction SilentlyContinue
99
98
Remove-Item - Recurse - Force " $privateSiteExtensionPath \$bitness \runtimes\osx" - ErrorAction SilentlyContinue
100
-
99
+
101
100
Write-Host " Removing python worker"
102
101
Remove-Item - Recurse - Force " $rootPath \workers\python" - ErrorAction SilentlyContinue
103
102
@@ -106,7 +105,7 @@ function CleanOutput([string] $rootPath) {
106
105
Get-ChildItem " $rootPath \workers\powershell" - Directory - ErrorAction SilentlyContinue |
107
106
ForEach-Object { Get-ChildItem " $ ( $_.FullName ) \runtimes" - Directory - Exclude $keepRuntimes } |
108
107
Remove-Item - Recurse - Force - ErrorAction SilentlyContinue
109
-
108
+
110
109
Write-Host " Current size: $ ( GetFolderSizeInMb $rootPath ) Mb"
111
110
}
112
111
@@ -115,9 +114,9 @@ function CreatePatchedSiteExtension([string] $siteExtensionPath) {
115
114
Write-Host " SiteExtensionPath is $siteExtensionPath "
116
115
$officialSiteExtensionPath = " $siteExtensionPath \$extensionVersion "
117
116
$baseVersion = " $majorMinorVersion .0"
118
- $baseZipPath = " $buildOutput \BaseZipDirectory"
119
- $baseExtractedPath = " $buildOutput \BaseZipDirectory\Extracted"
120
-
117
+ $baseZipPath = " $publishDir \BaseZipDirectory"
118
+ $baseExtractedPath = " $publishDir \BaseZipDirectory\Extracted"
119
+
121
120
# Try to download base version
122
121
New-Item - Itemtype " directory" - path " $baseZipPath " - Force > $null
123
122
New-Item - Itemtype " directory" - path " $baseExtractedPath " - Force > $null
@@ -131,7 +130,7 @@ function CreatePatchedSiteExtension([string] $siteExtensionPath) {
131
130
Expand-Archive - LiteralPath " $baseZipPath \Functions.$majorMinorVersion .0.zip" - DestinationPath " $baseExtractedPath "
132
131
133
132
# Create directory for patch
134
- $zipOutput = " $buildOutput \ZippedPatchSiteExtension"
133
+ $zipOutput = " $publishDir \ZippedPatchSiteExtension"
135
134
New-Item - Itemtype directory - path $zipOutput - Force > $null
136
135
137
136
# Copy extensions.xml as is
@@ -207,16 +206,21 @@ function CreatePatchedSiteExtension([string] $siteExtensionPath) {
207
206
208
207
function CreateSiteExtensions () {
209
208
$stopwatch = [System.Diagnostics.Stopwatch ]::StartNew()
210
- $siteExtensionPath = " $buildOutput \temp_extension"
209
+ $siteExtensionPath = " $publishDir \temp_extension"
210
+
211
+ if (Test-Path $siteExtensionPath ) {
212
+ Write-Host " Existing site extension path found. Deleting."
213
+ Remove-Item $siteExtensionPath - Recurse - Force | Out-Null
214
+ }
211
215
212
216
# The official site extension needs to be nested inside a folder with its version.
213
217
# Not using the suffix (eg: '-ci') here as it may not work correctly in a private stamp
214
218
$officialSiteExtensionPath = " $siteExtensionPath \$extensionVersion "
215
219
216
220
Write-Host " ======================================"
217
221
Write-Host " Copying build to temp directory to prepare for zipping official site extension."
218
- Copy-Item - Path $buildOutput \publish\win - x86\ - Destination $officialSiteExtensionPath \32bit - Force - Recurse > $null
219
- Copy-Item - Path $buildOutput \publish\win - x64 - Destination $officialSiteExtensionPath \64bit - Force - Recurse > $null
222
+ Copy-Item - Path $publishDir \release_win - x86\ - Destination $officialSiteExtensionPath \32bit - Force - Recurse > $null
223
+ Copy-Item - Path $publishDir \release_win - x64 - Destination $officialSiteExtensionPath \64bit - Force - Recurse > $null
220
224
Copy-Item - Path $officialSiteExtensionPath \32bit\applicationHost.xdt - Destination $officialSiteExtensionPath - Force > $null
221
225
Write-Host " Deleting workers directory: $officialSiteExtensionPath \32bit\workers"
222
226
Remove-Item - Recurse - Force " $officialSiteExtensionPath \32bit\workers" - ErrorAction SilentlyContinue
@@ -236,12 +240,12 @@ function CreateSiteExtensions() {
236
240
Write-Host " Done generating hashes for hard links into $siteExtensionPath /$extensionVersion "
237
241
Write-Host " ======================================"
238
242
Write-Host
239
-
240
- $zipOutput = " $buildOutput \SiteExtension"
243
+
244
+ $zipOutput = " $publishDir \SiteExtension"
241
245
$hashesForHardLinksPath = " $siteExtensionPath \$extensionVersion \$hashesForHardlinksFile "
242
246
New-Item - Itemtype directory - path $zipOutput - Force > $null
243
247
if ($minorVersionPrefix -eq " " ) {
244
- ZipContent $siteExtensionPath " $zipOutput \Functions.$extensionVersion$runtimeSuffix .zip"
248
+ ZipContent $siteExtensionPath " $zipOutput \Functions.$extensionVersion .zip"
245
249
} elseif ($minorVersionPrefix -eq " 8" ) {
246
250
Write-Host " ======================================"
247
251
# Only the "Functions" site extension supports hard links
@@ -250,24 +254,24 @@ function CreateSiteExtensions() {
250
254
# The .NET 8 host doesn't require any workers. Doing this to save space.
251
255
Write-Host " Removing workers before zipping."
252
256
# The host requires that this folder exists and it cannot be empty
253
- Remove-Item - Recurse - Force " $siteExtensionPath \$extensionVersion$runtimeSuffix \workers" - ErrorAction Stop
254
- New-Item - Path " $siteExtensionPath \$extensionVersion$runtimeSuffix " - Name " workers" - ItemType Directory - ErrorAction Stop | Out-Null
255
- Set-Content - Force - Path " $siteExtensionPath \$extensionVersion$runtimeSuffix \workers\this_folder_intentionally_empty.txt" - Value " .NET 8 builds do not have workers. However, this folder must contain at least one file." - ErrorAction Stop
257
+ Remove-Item - Recurse - Force " $siteExtensionPath \$extensionVersion \workers" - ErrorAction Stop
258
+ New-Item - Path " $siteExtensionPath \$extensionVersion " - Name " workers" - ItemType Directory - ErrorAction Stop | Out-Null
259
+ Set-Content - Force - Path " $siteExtensionPath \$extensionVersion \workers\this_folder_intentionally_empty.txt" - Value " .NET 8 builds do not have workers. However, this folder must contain at least one file." - ErrorAction Stop
256
260
Write-Host " ======================================"
257
261
Write-Host
258
- ZipContent $siteExtensionPath " $zipOutput \FunctionsInProc8.$extensionVersion$runtimeSuffix .zip"
262
+ ZipContent $siteExtensionPath " $zipOutput \FunctionsInProc8.$extensionVersion .zip"
259
263
} elseif ($minorVersionPrefix -eq " 6" ) {
260
264
# Only the "Functions" site extension supports hard links
261
265
Write-Host " ======================================"
262
266
Write-Host " MinorVersionPrefix is '6'. Removing $hashesForHardLinksPath before zipping."
263
267
Remove-Item - Force " $hashesForHardLinksPath " - ErrorAction Stop
264
268
Write-Host " ======================================"
265
269
Write-Host
266
- ZipContent $siteExtensionPath " $zipOutput \FunctionsInProc.$extensionVersion$runtimeSuffix .zip"
270
+ ZipContent $siteExtensionPath " $zipOutput \FunctionsInProc.$extensionVersion .zip"
267
271
}
268
272
269
273
# Create directory for content even if there is no patch build. This makes artifact uploading easier.
270
- $patchedContentDirectory = " $buildOutput \PatchedSiteExtension"
274
+ $patchedContentDirectory = " $publishDir \PatchedSiteExtension"
271
275
New-Item - Itemtype directory - path $patchedContentDirectory - Force > $null
272
276
273
277
# Construct patch
@@ -280,19 +284,19 @@ function CreateSiteExtensions() {
280
284
Write-Host " ======================================"
281
285
Write-Host
282
286
}
283
-
284
- Remove-Item $siteExtensionPath - Recurse - Force > $null
285
-
287
+
288
+ Remove-Item $siteExtensionPath - Recurse - Force > $null
289
+
286
290
Write-Host " ======================================"
287
291
$stopwatch.Reset ()
288
292
Write-Host " Copying build to temp directory to prepare for zipping private site extension."
289
- Copy-Item - Path $buildOutput \publish\win - x86\ - Destination $siteExtensionPath \SiteExtensions\Functions\32bit - Force - Recurse > $null
293
+ Copy-Item - Path $publishDir \release_win - x86\ - Destination $siteExtensionPath \SiteExtensions\Functions\32bit - Force - Recurse > $null
290
294
Copy-Item - Path $siteExtensionPath \SiteExtensions\Functions\32bit\applicationHost.xdt - Destination $siteExtensionPath \SiteExtensions\Functions - Force > $null
291
295
Write-Host " Done copying. Elapsed: $ ( $stopwatch.Elapsed ) "
292
296
Write-Host " ======================================"
293
297
Write-Host " "
294
-
295
- $zipOutput = " $buildOutput \PrivateSiteExtension"
298
+
299
+ $zipOutput = " $publishDir \PrivateSiteExtension"
296
300
New-Item - Itemtype directory - path $zipOutput - Force > $null
297
301
ZipContent $siteExtensionPath " $zipOutput \Functions.Private.$extensionVersion .win-x32.inproc.zip"
298
302
@@ -303,20 +307,18 @@ function WriteHashesFile([string] $directoryPath) {
303
307
New-Item - Path " $directoryPath /../temp_hashes" - ItemType Directory | Out-Null
304
308
$temp_current = (Get-Location )
305
309
Set-Location $directoryPath
306
- Get-ChildItem - Recurse $directoryPath | where { $_.PsIsContainer -eq $false } | Foreach-Object { " Hash:" + [System.Convert ]::ToBase64String([System.Text.Encoding ]::UTF8.GetBytes((Get-FileHash - Algorithm MD5 $_.FullName ).Hash)) + " FileName:" + (Resolve-Path - Relative - Path $_.FullName ) } | Out-File - FilePath " $directoryPath \..\temp_hashes\$hashesForHardlinksFile "
310
+ Get-ChildItem - Recurse $directoryPath | Where-Object { $_.PsIsContainer -eq $false } | Foreach-Object { " Hash:" + [System.Convert ]::ToBase64String([System.Text.Encoding ]::UTF8.GetBytes((Get-FileHash - Algorithm MD5 $_.FullName ).Hash)) + " FileName:" + (Resolve-Path - Relative - Path $_.FullName ) } | Out-File - FilePath " $directoryPath \..\temp_hashes\$hashesForHardlinksFile "
307
311
Move-Item - Path " $directoryPath /../temp_hashes/$hashesForHardlinksFile " - Destination " $directoryPath " - Force
308
312
Set-Location $temp_current
309
313
Remove-Item " $directoryPath /../temp_hashes" - Recurse - Force > $null
310
314
}
311
315
312
- Write-Host
313
- dotnet -- info
314
- Write-Host
315
- Write-Host " Output directory: $buildOutput "
316
- if (Test-Path $buildOutput ) {
316
+ Write-Host " Output directory: $publishDir "
317
+ if (Test-Path $publishDir ) {
317
318
Write-Host " Existing build output found. Deleting."
318
- Remove-Item $buildOutput - Recurse - Force - ErrorAction Stop
319
+ Remove-Item $publishDir - Recurse - Force - ErrorAction Stop
319
320
}
321
+
320
322
Write-Host " Extensions version: $extensionVersion "
321
323
Write-Host " "
322
324
0 commit comments