-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update azure-sdk-build-tools Repository Resource Refs in Yaml files (#…
…5174) * now produce standalone binaries on mac and linux agents as two different builds in the build stage * add entitlements file, sign during production of the binary * publish individual artifacts from the job, allowing us to download them individually as well * Update azure-sdk-build-tools Repository Resource Refs in Yaml files Co-authored-by: scbedd <[email protected]> Co-authored-by: semick-dev <[email protected]> Co-authored-by: Ben Broderick Phillips <[email protected]>
- Loading branch information
1 parent
32847c3
commit d4c712d
Showing
6 changed files
with
181 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "https://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>com.apple.security.cs.allow-dyld-environment-variables</key><true/> | ||
<key>com.apple.security.cs.allow-jit</key><true/> | ||
<key>com.apple.security.cs.debugger</key><true/> | ||
<key>com.apple.security.cs.disable-library-validation</key><true/> | ||
<key>com.apple.security.get-task-allow</key><true/> | ||
</dict> | ||
</plist> | ||
</xml> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
eng/pipelines/templates/scripts/assemble-dotnet-standalone-exe.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<# | ||
.SYNOPSIS | ||
Publishes a standalone dotnet executable to an artifact staging directory. | ||
.DESCRIPTION | ||
Assembles a standalone executable and places it within the given staging directory. This script takes care of any additional minutae that is required to | ||
enable a usable binary down the line after signing or notarization. | ||
.PARAMETER Rid | ||
The target platform. Takes the form of "osx-x64", "win-arm64", "linux-x64", etc. A full list is available here: https://learn.microsoft.com/en-us/dotnet/core/rid-catalog | ||
.PARAMETER ArtifactStagingDirectory | ||
The root directory which will receive the compressed standalone executable. | ||
.PARAMETER Target | ||
The targeted folder that should be built and assembled into a standalone executable. | ||
.PARAMETER Framework | ||
The targeted .NET framework. Defaults to "net6.0." | ||
#> | ||
param( | ||
[Parameter(mandatory=$true)] | ||
[string] $Rid, | ||
[Parameter(mandatory=$true)] | ||
[string] $Target, | ||
[Parameter(mandatory=$true)] | ||
[string] $ArtifactStagingDirectory, | ||
[Parameter(mandatory=$false)] | ||
[string] $Framework = "net6.0" | ||
) | ||
|
||
# resolves to <artifactfolder>/win-x64 | ||
$destinationArtifactFolder = Join-Path $ArtifactStagingDirectory $Rid | ||
|
||
# resolves to <artifactfolder>/win-x64/test-proxy-standalone-win-x64 (.zip or .tar.gz will be added as appropriate for platform) | ||
$destinationPathSegment = Join-Path $destinationArtifactFolder "$(Split-Path -Leaf "$Target")-standalone-$Rid" | ||
|
||
# resolves to tools/test-proxy/win-x64 | ||
$outputPath = Join-Path $Target $Rid | ||
|
||
# ensure the destination artifact directory exists | ||
if (!(Test-Path $destinationArtifactFolder)){ | ||
New-Item -Force -Path $destinationArtifactFolder -ItemType directory | ||
} | ||
|
||
Write-Host "dotnet publish -f $Framework -c Release -r $Rid -p:PublishSingleFile=true --self-contained --output $outputPath $Target" | ||
dotnet publish -f $Framework -c Release -r $Rid -p:PublishSingleFile=true --self-contained --output $outputPath $Target | ||
|
||
if ($LASTEXITCODE -ne 0) { | ||
Write-Error "dotnet publish failed with exit code $LASTEXITCODE." | ||
exit $LASTEXITCODE | ||
} | ||
|
||
# produce a tar.gz only for linux | ||
if ("$($Rid)".Contains("linux")){ | ||
# tar on powershell in linux has some weirdness. For instance, this is a proper call to tar when we don't want to include the relative path to the target folder | ||
# tar -cvzf -C tools/test-proxy/linux-arm64 blah.tar.gz tools/test-proxy/linux-arm64 | ||
# however when we use this, we actually get an error. To avoid this, we simply CD into the target directory before tar-ing it. | ||
Push-Location "$outputPath" | ||
# The sum contents within this folder will be: `appSettings.json`, `test-proxy.pdb`, `test-proxy` (the binary), and a certificate. | ||
# This statement grabs the first extensionless file within the produced binary folder, which will always be the binary we need to set the executable bit on. | ||
$binaryFile = (Get-ChildItem -Path . | Where-Object { !([System.IO.Path]::HasExtension($_)) } | Select-Object -First 1).ToString().Replace("`\","/") | ||
bash -c "chmod +x $binaryFile" | ||
tar -cvzf "$($destinationPathSegment).tar.gz" . | ||
Pop-Location | ||
} | ||
elseif("$($Rid)".Contains("osx")){ | ||
# need to codesign the binary with an entitlements file such that the signed and notarized binary will properly invoke on | ||
# a mac system. However, the `codesign` command is only available on a MacOS agent. With that being the case, we simply special case | ||
# this function here to ensure that the script does not fail outside of a MacOS agent. | ||
if ($IsMacOS) { | ||
$binaryFile = Get-ChildItem -Path $outputPath | Where-Object { !([System.IO.Path]::hasExtension($_)) } | Select-Object -First 1 | ||
$binaryFileBash = $binaryFile.ToString().Replace("`\","/") | ||
|
||
$entitlements = (Resolve-Path -Path (Join-Path $PSScriptRoot ".." ".." ".." "dotnet-executable-entitlements.plist")).ToString().Replace("`\", "/") | ||
|
||
bash -c "codesign --deep -s - -f --options runtime --entitlements $($entitlements) $($binaryFileBash)" | ||
bash -c "codesign -d --entitlements :- $($binaryFileBash)" | ||
} | ||
|
||
Compress-Archive -Path "$($outputPath)/*" -DestinationPath "$($destinationPathSegment).zip" | ||
} | ||
else { | ||
Compress-Archive -Path "$($outputPath)/*" -DestinationPath "$($destinationPathSegment).zip" | ||
} | ||
|
||
# clean up the uncompressed artifact directory | ||
Remove-Item -Recurse -Force -Path $outputPath | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters