Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ steps:

- pwsh: |
$ErrorActionPreference = "Stop"
./build.ps1 -Clean -Configuration Release -BuildNumber "$(buildNumber)"
./build.ps1 -Clean -Configuration Release -BuildNumber "$(buildNumber)" -AddSBOM -SBOMUtilSASUrl $env:SBOMUtilSASUrl
displayName: 'Build worker code'
env:
SBOMUtilSASUrl: $(SBOMUtilSASUrl)

- pwsh: ./build.ps1 -NoBuild -Test
displayName: 'Running UnitTest'
Expand Down
60 changes: 59 additions & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ param(
$Configuration = "Debug",

[string]
$BuildNumber = '0'
$BuildNumber = '0',

[switch]
$AddSBOM,

[string]
$SBOMUtilSASUrl
)

#Requires -Version 6.0
Expand Down Expand Up @@ -62,6 +68,35 @@ function Get-FunctionsCoreToolsDir {
}
}

function Install-SBOMUtil
{
if ([string]::IsNullOrEmpty($SBOMUtilSASUrl))
{
throw "The `$SBOMUtilSASUrl parameter cannot be null or empty when specifying the `$AddSBOM switch"
}

$MANIFESTOOLNAME = "ManifestTool"
Write-Host "Installing $MANIFESTOOLNAME..."

$MANIFESTOOL_DIRECTORY = Join-Path $PSScriptRoot $MANIFESTOOLNAME
Remove-Item -Recurse -Force $MANIFESTOOL_DIRECTORY -ErrorAction Ignore

Invoke-RestMethod -Uri $SBOMUtilSASUrl -OutFile "$MANIFESTOOL_DIRECTORY.zip"
Expand-Archive "$MANIFESTOOL_DIRECTORY.zip" -DestinationPath $MANIFESTOOL_DIRECTORY

$dllName = "Microsoft.ManifestTool.dll"
$manifestToolPath = "$MANIFESTOOL_DIRECTORY/$dllName"

if (-not (Test-Path $manifestToolPath))
{
throw "$MANIFESTOOL_DIRECTORY does not contain '$dllName'"
}

Write-Host 'Done.'

return $manifestToolPath
}

function Deploy-PowerShellWorker {
$ErrorActionPreference = 'Stop'

Expand Down Expand Up @@ -140,6 +175,29 @@ if (!$NoBuild.IsPresent) {
-OutFile "$PSScriptRoot/src/Modules/Microsoft.PowerShell.Management/Microsoft.PowerShell.Management.psd1"

dotnet publish -c $Configuration "/p:BuildNumber=$BuildNumber" $PSScriptRoot

if ($AddSBOM)
{
# Install manifest tool
$manifestTool = Install-SBOMUtil
Write-Log "manifestTool: $manifestTool "

# Generate manifest
$buildPath = "$PSScriptRoot/src/bin/$Configuration/$TargetFramework/publish"
$telemetryFilePath = Join-Path $PSScriptRoot ((New-Guid).Guid + ".json")
$packageName = "Microsoft.Azure.Functions.PowerShellWorker.nuspec"

# Delete the manifest folder if it exists
$manifestFolderPath = Join-Path $buildPath "_manifest"
if (Test-Path $manifestFolderPath)
{
Remove-Item $manifestFolderPath -Recurse -Force -ErrorAction Ignore
}

Write-Log "Running: dotnet $manifestTool generate -BuildDropPath $buildPath -BuildComponentPath $buildPath -Verbosity Information -t $telemetryFilePath"
& { dotnet $manifestTool generate -BuildDropPath $buildPath -BuildComponentPath $buildPath -Verbosity Information -t $telemetryFilePath -PackageName $packageName }
}

dotnet pack -c $Configuration "/p:BuildNumber=$BuildNumber" "$PSScriptRoot/package"
}

Expand Down
7 changes: 7 additions & 0 deletions tools/helper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ $IsWindowsEnv = [RuntimeInformation]::IsOSPlatform([OSPlatform]::Windows)
$RepoRoot = (Resolve-Path "$PSScriptRoot/..").Path

$DotnetSDKVersionRequirements = @{

# .NET SDK 3.1 is required by the Microsoft.ManifestTool.dll tool
'3.1' = @{
MinimalPatch = '415'
DefaultPatch = '415'
}

'6.0' = @{
MinimalPatch = '100'
DefaultPatch = '100'
Expand Down