Skip to content

Commit 691bde1

Browse files
jviaufabiocav
authored andcommitted
[pack] Use dotnet common artifacts output (#9858)
* Use dotnet common artifacts output * Fix test paths * Fix more tests * Compress-Archive fix attempt * Fix more tests * Remove verbose log from build script * Update build-extensions.ps1 * Remove release_* from esrp signing * Force build * Allow for packing via --pack * Use powershell core --pack * Force build --pack * Fix pwsh --pack * Upgrade back to .NET8 * Fix copy-paste error * Fix Verify_DepsJsonChanges * Undo SDK upgrade
1 parent 73c7731 commit 691bde1

38 files changed

+170
-135
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
bin
22
obj
3+
out
34
csx
45
.vs
56
.vscode

Directory.Build.props

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Project>
2+
3+
<PropertyGroup>
4+
<ArtifactsPath>$(MSBuildThisFileDirectory)out</ArtifactsPath>
5+
<ArtifactsPublishOutputName>pub</ArtifactsPublishOutputName>
6+
<ArtifactsPackageOutputName>pkg</ArtifactsPackageOutputName>
7+
</PropertyGroup>
8+
9+
</Project>

azure-pipelines.yml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ jobs:
4848
filePath: '$(Build.Repository.LocalPath)\build\initialize-pipeline.ps1'
4949
arguments: -minorVersionPrefix "$(minorVersionPrefix)"
5050
showWarnings: true
51+
pwsh: true
5152

5253
- job: BuildArtifacts
5354
dependsOn: InitializePipeline
@@ -77,15 +78,15 @@ jobs:
7778
filePath: '$(Build.Repository.LocalPath)\build\check-vulnerabilities.ps1'
7879
- task: CopyFiles@2
7980
inputs:
80-
SourceFolder: '$(Build.Repository.LocalPath)\buildoutput'
81-
Contents: '**\*.zip'
81+
SourceFolder: 'out/pub/WebJobs.Script.WebHost'
82+
Contents: '**/*.zip'
8283
TargetFolder: '$(Build.ArtifactStagingDirectory)'
8384
- task: DotNetCoreCLI@2
8485
displayName: 'Build host packages'
8586
inputs:
8687
command: 'custom'
8788
custom: 'pack'
88-
arguments: -o packages -p:BuildNumber=$(buildNumber) -c Release $(packSuffixSwitch)
89+
arguments: -p:BuildNumber=$(buildNumber) -c Release $(packSuffixSwitch)
8990
projects: |
9091
**\WebJobs.Script.csproj
9192
**\WebJobs.Script.WebHost.csproj
@@ -102,7 +103,7 @@ jobs:
102103
displayName: 'ESRP CodeSigning: Strong Name and Authenticode'
103104
inputs:
104105
ConnectedServiceName: 'ESRP Service'
105-
FolderPath: 'src\WebJobs.Script.Abstractions\bin\Release'
106+
FolderPath: 'out/bin/WebJobs.Script.Abstractions/release'
106107
Pattern: Microsoft.Azure.WebJobs.Script.Abstractions*.dll
107108
signConfigType: inlineSignParams
108109
inlineOperation: |
@@ -137,14 +138,14 @@ jobs:
137138
inputs:
138139
command: 'custom'
139140
custom: 'pack'
140-
arguments: '--no-build -c Release -o packages'
141+
arguments: '--no-build -c Release'
141142
projects: |
142143
**\WebJobs.Script.Abstractions.csproj
143144
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@2
144145
displayName: 'ESRP CodeSigning: Nupkg'
145146
inputs:
146147
ConnectedServiceName: 'ESRP Service'
147-
FolderPath: 'packages'
148+
FolderPath: 'out/pkg/release'
148149
Pattern: 'Microsoft.Azure.WebJobs.Script.Abstractions*.nupkg'
149150
signConfigType: inlineSignParams
150151
inlineOperation: |
@@ -168,8 +169,8 @@ jobs:
168169
displayName: 'ESRP CodeSigning: Strong Name and Authenticode'
169170
inputs:
170171
ConnectedServiceName: 'ESRP Service'
171-
FolderPath: 'tools\ExtensionsMetadataGenerator\src\ExtensionsMetadataGenerator\bin\Release'
172-
Pattern: Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator*.dll
172+
FolderPath: 'out/bin/ExtensionsMetadataGenerator'
173+
Pattern: 'Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator*.dll'
173174
signConfigType: inlineSignParams
174175
inlineOperation: |
175176
[
@@ -218,15 +219,15 @@ jobs:
218219
inputs:
219220
command: 'custom'
220221
custom: 'pack'
221-
arguments: '--no-build -c Release -o packages $(emgSuffixSwitch)'
222+
arguments: '--no-build -c Release $(emgSuffixSwitch)'
222223
projects: |
223224
**\ExtensionsMetadataGenerator.csproj
224225
steps:
225226
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@2
226227
displayName: 'ESRP CodeSigning: Nupkg'
227228
inputs:
228229
ConnectedServiceName: 'ESRP Service'
229-
FolderPath: 'packages'
230+
FolderPath: 'out/pkg/release'
230231
Pattern: 'Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator*.nupkg'
231232
signConfigType: inlineSignParams
232233
inlineOperation: |
@@ -291,9 +292,9 @@ jobs:
291292
- task: ManifestGeneratorTask@0
292293
displayName: 'SBOM Generation Task - NugetPackages'
293294
inputs:
294-
BuildDropPath: '$(Build.Repository.LocalPath)\packages'
295+
BuildDropPath: 'out/pkg/release'
295296
Verbosity: 'Information'
296-
- publish: $(Build.Repository.LocalPath)\packages
297+
- publish: out/pkg/release
297298
artifact: NugetPackages
298299

299300
- job: RunUnitTests

build/build-extensions.ps1

Lines changed: 62 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
param (
2-
[string]$buildNumber = "0",
2+
[string]$buildNumber = "0",
33
[string]$suffix = "",
44
[ValidateSet("6", "8", "")][string]$minorVersionPrefix = "",
55
[string]$hashesForHardlinksFile = "hashesForHardlinks.txt"
66
)
77

8+
Import-Module "$PSScriptRoot\Get-AzureFunctionsVersion.psm1" -Force
89
$rootDir = Split-Path -Parent $PSScriptRoot
9-
$buildOutput = Join-Path $rootDir "buildoutput"
10+
$outDir = "$rootDir\out"
11+
$publishDir = "$outDir\pub\WebJobs.Script.WebHost"
1012

11-
Import-Module $PSScriptRoot\Get-AzureFunctionsVersion -Force
1213
$extensionVersion = Get-AzureFunctionsVersion $buildNumber $suffix $minorVersionPrefix
1314
Write-Host "Site extension version: $extensionVersion"
1415

@@ -19,49 +20,44 @@ $patchVersion = [int]$versionParts[2]
1920
$isPatch = $patchVersion -gt 0
2021
Write-Host "MajorMinorVersion is '$majorMinorVersion'. Patch version is '$patchVersion'. IsPatch: '$isPatch'"
2122

22-
function ZipContent([string] $sourceDirectory, [string] $target)
23-
{
23+
function ZipContent([string] $sourceDirectory, [string] $target) {
2424
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
25-
25+
2626
Write-Host "======================================"
2727
Write-Host "Zipping $sourceDirectory into $target"
28-
28+
2929
if (Test-Path $target) {
3030
Remove-Item $target
3131
}
32+
3233
Add-Type -assembly "system.io.compression.filesystem"
3334
[IO.Compression.ZipFile]::CreateFromDirectory($sourceDirectory, $target)
34-
35+
3536
Write-Host "Done zipping $target. Elapsed: $($stopwatch.Elapsed)"
3637
Write-Host "======================================"
3738
Write-Host ""
3839
}
3940

4041
function BuildRuntime([string] $targetRid, [bool] $isSelfContained) {
4142
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
42-
$runtimeSuffix = ".$targetRid"
43-
$ridSwitch = ""
44-
45-
$publishTarget = "$buildOutput\publish\$targetRid"
46-
$symbolsTarget = "$buildOutput\symbols\$targetRid"
4743

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"
4946
if (-not (Test-Path $projectPath))
5047
{
5148
throw "Project path '$projectPath' does not exist."
5249
}
5350

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"
5552

5653
Write-Host "======================================"
5754
Write-Host "Building $targetRid"
5855
Write-Host " Self-Contained: $isSelfContained"
59-
Write-Host " Output Directory: $publishTarget"
60-
Write-Host " Symbols Directory: $symbolsTarget"
56+
Write-Host " Publish Directory: $publishTarget"
6157
Write-Host ""
6258
Write-Host "dotnet $cmd"
6359
Write-Host ""
64-
60+
6561
& dotnet $cmd
6662

6763
if ($LASTEXITCODE -ne 0)
@@ -70,20 +66,23 @@ function BuildRuntime([string] $targetRid, [bool] $isSelfContained) {
7066
}
7167

7268
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
7882
Write-Host ""
7983
Write-Host "Done building $targetRid. Elapsed: $($stopwatch.Elapsed)"
8084
Write-Host "======================================"
8185
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"
8786
}
8887

8988
function GetFolderSizeInMb([string] $rootPath) {
@@ -93,11 +92,11 @@ function GetFolderSizeInMb([string] $rootPath) {
9392
function CleanOutput([string] $rootPath) {
9493
Write-Host "Cleaning build output under $rootPath"
9594
Write-Host " Current size: $(GetFolderSizeInMb $rootPath) Mb"
96-
95+
9796
Write-Host " Removing any linux and osx runtimes"
9897
Remove-Item -Recurse -Force "$privateSiteExtensionPath\$bitness\runtimes\linux" -ErrorAction SilentlyContinue
9998
Remove-Item -Recurse -Force "$privateSiteExtensionPath\$bitness\runtimes\osx" -ErrorAction SilentlyContinue
100-
99+
101100
Write-Host " Removing python worker"
102101
Remove-Item -Recurse -Force "$rootPath\workers\python" -ErrorAction SilentlyContinue
103102

@@ -106,7 +105,7 @@ function CleanOutput([string] $rootPath) {
106105
Get-ChildItem "$rootPath\workers\powershell" -Directory -ErrorAction SilentlyContinue |
107106
ForEach-Object { Get-ChildItem "$($_.FullName)\runtimes" -Directory -Exclude $keepRuntimes } |
108107
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
109-
108+
110109
Write-Host " Current size: $(GetFolderSizeInMb $rootPath) Mb"
111110
}
112111

@@ -115,9 +114,9 @@ function CreatePatchedSiteExtension([string] $siteExtensionPath) {
115114
Write-Host "SiteExtensionPath is $siteExtensionPath"
116115
$officialSiteExtensionPath = "$siteExtensionPath\$extensionVersion"
117116
$baseVersion = "$majorMinorVersion.0"
118-
$baseZipPath = "$buildOutput\BaseZipDirectory"
119-
$baseExtractedPath = "$buildOutput\BaseZipDirectory\Extracted"
120-
117+
$baseZipPath = "$publishDir\BaseZipDirectory"
118+
$baseExtractedPath = "$publishDir\BaseZipDirectory\Extracted"
119+
121120
# Try to download base version
122121
New-Item -Itemtype "directory" -path "$baseZipPath" -Force > $null
123122
New-Item -Itemtype "directory" -path "$baseExtractedPath" -Force > $null
@@ -131,7 +130,7 @@ function CreatePatchedSiteExtension([string] $siteExtensionPath) {
131130
Expand-Archive -LiteralPath "$baseZipPath\Functions.$majorMinorVersion.0.zip" -DestinationPath "$baseExtractedPath"
132131

133132
# Create directory for patch
134-
$zipOutput = "$buildOutput\ZippedPatchSiteExtension"
133+
$zipOutput = "$publishDir\ZippedPatchSiteExtension"
135134
New-Item -Itemtype directory -path $zipOutput -Force > $null
136135

137136
# Copy extensions.xml as is
@@ -207,16 +206,21 @@ function CreatePatchedSiteExtension([string] $siteExtensionPath) {
207206

208207
function CreateSiteExtensions() {
209208
$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+
}
211215

212216
# The official site extension needs to be nested inside a folder with its version.
213217
# Not using the suffix (eg: '-ci') here as it may not work correctly in a private stamp
214218
$officialSiteExtensionPath = "$siteExtensionPath\$extensionVersion"
215219

216220
Write-Host "======================================"
217221
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
220224
Copy-Item -Path $officialSiteExtensionPath\32bit\applicationHost.xdt -Destination $officialSiteExtensionPath -Force > $null
221225
Write-Host " Deleting workers directory: $officialSiteExtensionPath\32bit\workers"
222226
Remove-Item -Recurse -Force "$officialSiteExtensionPath\32bit\workers" -ErrorAction SilentlyContinue
@@ -236,12 +240,12 @@ function CreateSiteExtensions() {
236240
Write-Host "Done generating hashes for hard links into $siteExtensionPath/$extensionVersion"
237241
Write-Host "======================================"
238242
Write-Host
239-
240-
$zipOutput = "$buildOutput\SiteExtension"
243+
244+
$zipOutput = "$publishDir\SiteExtension"
241245
$hashesForHardLinksPath = "$siteExtensionPath\$extensionVersion\$hashesForHardlinksFile"
242246
New-Item -Itemtype directory -path $zipOutput -Force > $null
243247
if ($minorVersionPrefix -eq "") {
244-
ZipContent $siteExtensionPath "$zipOutput\Functions.$extensionVersion$runtimeSuffix.zip"
248+
ZipContent $siteExtensionPath "$zipOutput\Functions.$extensionVersion.zip"
245249
} elseif ($minorVersionPrefix -eq "8") {
246250
Write-Host "======================================"
247251
# Only the "Functions" site extension supports hard links
@@ -250,24 +254,24 @@ function CreateSiteExtensions() {
250254
# The .NET 8 host doesn't require any workers. Doing this to save space.
251255
Write-Host "Removing workers before zipping."
252256
# 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
256260
Write-Host "======================================"
257261
Write-Host
258-
ZipContent $siteExtensionPath "$zipOutput\FunctionsInProc8.$extensionVersion$runtimeSuffix.zip"
262+
ZipContent $siteExtensionPath "$zipOutput\FunctionsInProc8.$extensionVersion.zip"
259263
} elseif ($minorVersionPrefix -eq "6") {
260264
# Only the "Functions" site extension supports hard links
261265
Write-Host "======================================"
262266
Write-Host "MinorVersionPrefix is '6'. Removing $hashesForHardLinksPath before zipping."
263267
Remove-Item -Force "$hashesForHardLinksPath" -ErrorAction Stop
264268
Write-Host "======================================"
265269
Write-Host
266-
ZipContent $siteExtensionPath "$zipOutput\FunctionsInProc.$extensionVersion$runtimeSuffix.zip"
270+
ZipContent $siteExtensionPath "$zipOutput\FunctionsInProc.$extensionVersion.zip"
267271
}
268272

269273
# Create directory for content even if there is no patch build. This makes artifact uploading easier.
270-
$patchedContentDirectory = "$buildOutput\PatchedSiteExtension"
274+
$patchedContentDirectory = "$publishDir\PatchedSiteExtension"
271275
New-Item -Itemtype directory -path $patchedContentDirectory -Force > $null
272276

273277
# Construct patch
@@ -280,19 +284,19 @@ function CreateSiteExtensions() {
280284
Write-Host "======================================"
281285
Write-Host
282286
}
283-
284-
Remove-Item $siteExtensionPath -Recurse -Force > $null
285-
287+
288+
Remove-Item $siteExtensionPath -Recurse -Force > $null
289+
286290
Write-Host "======================================"
287291
$stopwatch.Reset()
288292
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
290294
Copy-Item -Path $siteExtensionPath\SiteExtensions\Functions\32bit\applicationHost.xdt -Destination $siteExtensionPath\SiteExtensions\Functions -Force > $null
291295
Write-Host "Done copying. Elapsed: $($stopwatch.Elapsed)"
292296
Write-Host "======================================"
293297
Write-Host ""
294-
295-
$zipOutput = "$buildOutput\PrivateSiteExtension"
298+
299+
$zipOutput = "$publishDir\PrivateSiteExtension"
296300
New-Item -Itemtype directory -path $zipOutput -Force > $null
297301
ZipContent $siteExtensionPath "$zipOutput\Functions.Private.$extensionVersion.win-x32.inproc.zip"
298302

@@ -303,20 +307,18 @@ function WriteHashesFile([string] $directoryPath) {
303307
New-Item -Path "$directoryPath/../temp_hashes" -ItemType Directory | Out-Null
304308
$temp_current = (Get-Location)
305309
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"
307311
Move-Item -Path "$directoryPath/../temp_hashes/$hashesForHardlinksFile" -Destination "$directoryPath" -Force
308312
Set-Location $temp_current
309313
Remove-Item "$directoryPath/../temp_hashes" -Recurse -Force > $null
310314
}
311315

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) {
317318
Write-Host " Existing build output found. Deleting."
318-
Remove-Item $buildOutput -Recurse -Force -ErrorAction Stop
319+
Remove-Item $publishDir -Recurse -Force -ErrorAction Stop
319320
}
321+
320322
Write-Host "Extensions version: $extensionVersion"
321323
Write-Host ""
322324

0 commit comments

Comments
 (0)