Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SiteExtension.proj to replace build-extension.ps1 #10168

Open
wants to merge 48 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
7cdc983
Add SiteExtension.proj
jviau Mar 21, 2024
f6781da
Publish workers, hash hard links
jviau Apr 9, 2024
a83720f
Add workers.props, avoid publishing worker files
jviau Apr 16, 2024
d5355b5
Refactor how worker is packaged
jviau Apr 19, 2024
63572fc
Add PrivateSiteExtension
jviau Apr 22, 2024
c3a6504
Fix duplicate build and file write error
jviau May 10, 2024
fd25b68
Comment and split out powershell regex match
jviau May 10, 2024
f3bcf1d
Fix MoveSymbols
jviau May 10, 2024
493dfd1
Publish PrivateSiteExtension
jviau May 10, 2024
362192a
Remove Python worker from private extension
jviau May 10, 2024
ded5dbc
Zip site extension artifacts
jviau May 13, 2024
d51de30
Clean dotnet worker files
jviau May 14, 2024
0efa966
Default ZipArtifactsPath to PackageOutputPath
jviau May 15, 2024
b4e13f7
Add comments, update dotnet sdk
jviau May 15, 2024
e7bfa31
Add explicit CI restore stage
jviau May 15, 2024
933b779
Split out build stage as well
jviau May 15, 2024
f7fd676
Add python.props back in with redirection message
jviau May 15, 2024
b7eb4e7
Fix integration build issue
jviau May 15, 2024
d7de7c5
Fix symbols output
jviau May 15, 2024
100e017
Revert python.props changes
jviau May 15, 2024
5a68e5c
Revert global.json change
jviau May 15, 2024
bdef249
Extract build site extension into template
jviau May 15, 2024
06291ab
Remove build-extension.ps1
jviau May 15, 2024
921856b
Add build-extensions.ps1 back, with error directing to replacement
jviau May 15, 2024
4181e94
Fix log publishing
jviau May 15, 2024
be3c120
Fix check-vuln placement
jviau May 15, 2024
619fbb9
Fix deletion of code-sign summary files
jviau May 16, 2024
3bd60b6
Fix symbol SBOM and artifact
jviau May 16, 2024
a5d5fef
Add single/multi-tfm support for SiteExtension.proj
jviau Jun 3, 2024
1175ff4
Fix end-of-file line breaks
jviau Jun 3, 2024
da5a5a6
Merge branch 'dev' into jviau/eng/site-proj
jviau Jun 12, 2024
4970854
Merge branch 'dev' into jviau/eng/site-proj
jviau Jul 17, 2024
e978655
Merge branch 'dev' into jviau/eng/site-proj
jviau Jul 25, 2024
3b663d7
Extract Workers to their own props files
jviau Jul 25, 2024
298419f
Fix ZipPublish when zip not specified
jviau Jul 26, 2024
f6e71ee
Merge remote-tracking branch 'upstream/dev' into jviau/eng/site-proj
jviau Jul 26, 2024
4b4983f
Remove redundant python removal
jviau Jul 26, 2024
c1dcc49
.proj -> .csproj
jviau Jul 26, 2024
a158673
Remove minorVersionPrefix
jviau Jul 26, 2024
a3c35fa
Update CODEOWNERS
jviau Jul 26, 2024
05e0bc2
Add EnsureWorkersFolder target
jviau Jul 26, 2024
f7a9825
Fix windows build
jviau Jul 29, 2024
d74a7fa
Pack linux artifact
jviau Jul 29, 2024
9e5bb6f
Add release config
jviau Jul 29, 2024
e116ada
Fix nuget signing path
jviau Jul 29, 2024
e5fac91
Merge branch 'dev' into jviau/eng/site-proj
jviau Jul 30, 2024
e69c425
Add condition for hard link hashes
jviau Jul 30, 2024
2e55135
Merge remote-tracking branch 'upstream/dev' into jviau/eng/site-proj
jviau Oct 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

# Adding codeowner for Python specific files such that GitHub automatically adds python folks as a reviewer.
build/python.props @vrdmr @gavin-aguiar @YunchuWang @pdthummar @hallvictoria
eng/build/Workers.Python.props @vrdmr @gavin-aguiar @YunchuWang @pdthummar @hallvictoria

# Deps.json validation file
test/WebJobs.Script.Tests/Microsoft.Azure.WebJobs.Script.WebHost.deps.json @fabiocav @brettsam @mathewc
Expand Down
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<PropertyGroup>
<RepoRoot>$(MSBuildThisFileDirectory)</RepoRoot>
<EngRoot>$(RepoRoot)eng/</EngRoot>
<TargetsRoot>$(EngRoot)build/</TargetsRoot>
</PropertyGroup>

<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>

<Import Project="$(EngRoot)build/Engineering.targets" />
<Import Project="$(TargetsRoot)Engineering.targets" />

</Project>
220 changes: 1 addition & 219 deletions build/build-extensions.ps1
Original file line number Diff line number Diff line change
@@ -1,219 +1 @@
param (
[string]$buildNumber = "0",
[string]$suffix = "",
[ValidateSet("6", "8", "")][string]$minorVersionPrefix = "",
[string]$hashesForHardlinksFile = "hashesForHardlinks.txt"
)

Import-Module "$PSScriptRoot\Get-AzureFunctionsVersion.psm1" -Force
$rootDir = Split-Path -Parent $PSScriptRoot
$outDir = "$rootDir\out"
$publishDir = "$outDir\pub\WebJobs.Script.WebHost"

$extensionVersion = Get-AzureFunctionsVersion $buildNumber $suffix $minorVersionPrefix
Write-Host "Site extension version: $extensionVersion"

function ZipContent([string] $sourceDirectory, [string] $target) {
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()

Write-Host "======================================"
Write-Host "Zipping $sourceDirectory into $target"

if (Test-Path $target) {
Remove-Item $target
}

Add-Type -assembly "system.io.compression.filesystem"
[IO.Compression.ZipFile]::CreateFromDirectory($sourceDirectory, $target)

Write-Host "Done zipping $target. Elapsed: $($stopwatch.Elapsed)"
Write-Host "======================================"
Write-Host ""
}

function BuildRuntime([string] $targetRid, [bool] $isSelfContained) {
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()

$publishTarget = "$publishDir\release_$targetRid"
$projectPath = "$rootDir\src\WebJobs.Script.WebHost\WebJobs.Script.WebHost.csproj"
if (-not (Test-Path $projectPath))
{
throw "Project path '$projectPath' does not exist."
}

$cmd = "publish", $projectPath , "-r", "$targetRid", "--self-contained", "$isSelfContained", "-v", "m", "-c", "Release", "-p:IsPackable=false", "-p:BuildNumber=$buildNumber", "-p:MinorVersionPrefix=$minorVersionPrefix"

Write-Host "======================================"
Write-Host "Building $targetRid"
Write-Host " Self-Contained: $isSelfContained"
Write-Host " Publish Directory: $publishTarget"
Write-Host ""
Write-Host "dotnet $cmd"
Write-Host ""

& dotnet $cmd

if ($LASTEXITCODE -ne 0)
{
exit $LASTEXITCODE
}

Write-Host ""
$symbols = Get-ChildItem -Path $publishTarget -Filter *.pdb
$symbols += Get-ChildItem -Path "$publishTarget\workers\dotnet-isolated\*" -Include "*.pdb", "*.dbg" -Recurse
Write-Host "Zipping symbols: $($symbols.Count) symbols found"

$symbolsPath = "$publishDir\Symbols"
if (!(Test-Path -PathType Container $symbolsPath)) {
New-Item -ItemType Directory -Path $symbolsPath | Out-Null
}

$symbols | Compress-Archive -DestinationPath "$symbolsPath\Functions.Symbols.$extensionVersion.$targetRid.zip" | Out-Null
$symbols | Remove-Item | Out-Null

Write-Host ""
CleanOutput $publishTarget
Write-Host ""
Write-Host "Done building $targetRid. Elapsed: $($stopwatch.Elapsed)"
Write-Host "======================================"
Write-Host ""
}

function GetFolderSizeInMb([string] $rootPath) {
return [math]::Round((Get-ChildItem $rootPath -Recurse | Measure-Object -Property Length -Sum -ErrorAction Stop).Sum / 1Mb, 2)
}

function CleanOutput([string] $rootPath) {
Write-Host "Cleaning build output under $rootPath"
Write-Host " Current size: $(GetFolderSizeInMb $rootPath) Mb"

Write-Host " Removing any linux and osx runtimes"
Remove-Item -Recurse -Force "$privateSiteExtensionPath\$bitness\runtimes\linux" -ErrorAction SilentlyContinue
Remove-Item -Recurse -Force "$privateSiteExtensionPath\$bitness\runtimes\osx" -ErrorAction SilentlyContinue

Write-Host " Removing python worker"
Remove-Item -Recurse -Force "$rootPath\workers\python" -ErrorAction SilentlyContinue

$keepRuntimes = @('win', 'win-x86', 'win10-x86', 'win-x64', 'win10-x64')
Write-Host " Removing all powershell runtimes except $keepRuntimes"
Get-ChildItem "$rootPath\workers\powershell" -Directory -ErrorAction SilentlyContinue |
ForEach-Object { Get-ChildItem "$($_.FullName)\runtimes" -Directory -Exclude $keepRuntimes } |
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue

Write-Host " Removing FunctionsNetHost(linux executable) and dependencies from dotnet-isolated worker"
$dotnetIsolatedBinPath = Join-Path $rootPath "workers\dotnet-isolated\bin"
if (Test-Path $dotnetIsolatedBinPath) {
Remove-Item -Path (Join-Path $dotnetIsolatedBinPath "FunctionsNetHost") -ErrorAction SilentlyContinue
Get-ChildItem -Path $dotnetIsolatedBinPath -Filter "*.so" | Remove-Item -ErrorAction SilentlyContinue
}

Write-Host " Current size: $(GetFolderSizeInMb $rootPath) Mb"
}

function CreateSiteExtensions() {
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
$siteExtensionPath = "$publishDir\temp_extension"

if (Test-Path $siteExtensionPath) {
Write-Host " Existing site extension path found. Deleting."
Remove-Item $siteExtensionPath -Recurse -Force | Out-Null
}

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

Write-Host "======================================"
Write-Host "Copying build to temp directory to prepare for zipping official site extension."
Copy-Item -Path $publishDir\release_win-x86\ -Destination $officialSiteExtensionPath\32bit -Force -Recurse > $null
Copy-Item -Path $publishDir\release_win-x64 -Destination $officialSiteExtensionPath\64bit -Force -Recurse > $null
Copy-Item -Path $officialSiteExtensionPath\32bit\applicationHost.xdt -Destination $officialSiteExtensionPath -Force > $null
Write-Host " Deleting workers directory: $officialSiteExtensionPath\32bit\workers"
Remove-Item -Recurse -Force "$officialSiteExtensionPath\32bit\workers" -ErrorAction SilentlyContinue
Write-Host " Moving workers directory: $officialSiteExtensionPath\64bit\workers to $officialSiteExtensionPath\workers"
Move-Item -Path "$officialSiteExtensionPath\64bit\workers" -Destination "$officialSiteExtensionPath\workers"

# This goes in the root dir
Copy-Item $rootDir\src\WebJobs.Script.WebHost\extension.xml $siteExtensionPath > $null

Write-Host "Done copying. Elapsed: $($stopwatch.Elapsed)"
Write-Host "======================================"
Write-Host ""

Write-Host "======================================"
Write-Host "Generating hashes for hard links"
WriteHashesFile $siteExtensionPath/$extensionVersion
Write-Host "Done generating hashes for hard links into $siteExtensionPath/$extensionVersion"
Write-Host "======================================"
Write-Host

$zipOutput = "$publishDir\SiteExtension"
$hashesForHardLinksPath = "$siteExtensionPath\$extensionVersion\$hashesForHardlinksFile"
New-Item -Itemtype directory -path $zipOutput -Force > $null
if ($minorVersionPrefix -eq "") {
ZipContent $siteExtensionPath "$zipOutput\Functions.$extensionVersion.zip"
} elseif ($minorVersionPrefix -eq "8") {
Write-Host "======================================"
# Only the "Functions" site extension supports hard links
Write-Host "MinorVersionPrefix is '8'. Removing $hashesForHardLinksPath before zipping."
Remove-Item -Force "$hashesForHardLinksPath" -ErrorAction Stop
# The .NET 8 host doesn't require any workers. Doing this to save space.
Write-Host "Removing workers before zipping."
# The host requires that this folder exists and it cannot be empty
Remove-Item -Recurse -Force "$siteExtensionPath\$extensionVersion\workers" -ErrorAction Stop
New-Item -Path "$siteExtensionPath\$extensionVersion" -Name "workers" -ItemType Directory -ErrorAction Stop | Out-Null
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
Write-Host "======================================"
Write-Host
ZipContent $siteExtensionPath "$zipOutput\FunctionsInProc8.$extensionVersion.zip"
} elseif ($minorVersionPrefix -eq "6") {
# Only the "Functions" site extension supports hard links
Write-Host "======================================"
Write-Host "MinorVersionPrefix is '6'. Removing $hashesForHardLinksPath before zipping."
Remove-Item -Force "$hashesForHardLinksPath" -ErrorAction Stop
Write-Host "======================================"
Write-Host
ZipContent $siteExtensionPath "$zipOutput\FunctionsInProc.$extensionVersion.zip"
}

Remove-Item $siteExtensionPath -Recurse -Force > $null

Write-Host "======================================"
$stopwatch.Reset()
Write-Host "Copying build to temp directory to prepare for zipping private site extension."
Copy-Item -Path $publishDir\release_win-x86\ -Destination $siteExtensionPath\SiteExtensions\Functions\32bit -Force -Recurse > $null
Copy-Item -Path $siteExtensionPath\SiteExtensions\Functions\32bit\applicationHost.xdt -Destination $siteExtensionPath\SiteExtensions\Functions -Force > $null
Write-Host "Done copying. Elapsed: $($stopwatch.Elapsed)"
Write-Host "======================================"
Write-Host ""

$zipOutput = "$publishDir\PrivateSiteExtension"
New-Item -Itemtype directory -path $zipOutput -Force > $null
ZipContent $siteExtensionPath "$zipOutput\Functions.Private.$extensionVersion.win-x32.inproc.zip"

Remove-Item $siteExtensionPath -Recurse -Force > $null
}

function WriteHashesFile([string] $directoryPath) {
New-Item -Path "$directoryPath/../temp_hashes" -ItemType Directory | Out-Null
$temp_current = (Get-Location)
Set-Location $directoryPath
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"
Move-Item -Path "$directoryPath/../temp_hashes/$hashesForHardlinksFile" -Destination "$directoryPath" -Force
Set-Location $temp_current
Remove-Item "$directoryPath/../temp_hashes" -Recurse -Force > $null
}

Write-Host "Output directory: $publishDir"
if (Test-Path $publishDir) {
Write-Host " Existing build output found. Deleting."
Remove-Item $publishDir -Recurse -Force -ErrorAction Stop
}

Write-Host "Extensions version: $extensionVersion"
Write-Host ""

BuildRuntime "win-x86"
BuildRuntime "win-x64"

CreateSiteExtensions
Write-Error "This script is no longer used. Instead, publish src/WebJobs.Script.SiteExtension/WebJobs.Script.SiteExtension.proj directly."
4 changes: 2 additions & 2 deletions build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
<PatchVersion>1</PatchVersion>
<BuildNumber Condition="'$(BuildNumber)' == '' ">0</BuildNumber>
<PreviewVersion></PreviewVersion>

<!-- During previews, always generate this suffix, even for official releases -->
<_VersionSuffix Condition="'$(PreviewVersion)' != ''">-preview.$(PreviewVersion).$(BuildNumber)</_VersionSuffix>
<!-- Otherwise, use the suffix directly, adding a '-' -->
<_VersionSuffix Condition="'$(PreviewVersion)' == '' and '$(VersionSuffix)' != ''">-$(VersionSuffix)</_VersionSuffix>

<VersionPrefix>$(MajorVersion).$(MinorVersion).$(PatchVersion)</VersionPrefix>
<Version>$(VersionPrefix)$(_VersionSuffix)</Version>
<AssemblyVersion>$(MajorVersion).$(MinorVersion).0.0</AssemblyVersion>
Expand Down
7 changes: 4 additions & 3 deletions build/python.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Project>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.PythonWorker" Version="4.30.3" />
</ItemGroup>
<!-- See /eng/build/Workers.Python.props -->
<Target Name="_DoNotImport" BeforeTargets="Build">
<Error Text="This file should not be imported. Import '$(TargetsRoot)Workers.props'." />
</Target>
</Project>
Loading
Loading