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
23 changes: 14 additions & 9 deletions build-tools/automation/yaml-templates/apk-instrumentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ steps:
$env:PATH = "${DOTNET_ROOT};$env:PATH"
$dotnetPath = "${DOTNET_ROOT}\dotnet.exe"
}
# Workaround for https://github.com/dotnet/sdk/pull/55581
$env:DOTNET_HOST_PATH = $dotnetPath
& $dotnetPath test $projectFile -bl:${{ parameters.xaSourcePath }}/bin/Test${{ parameters.configuration }}/run-${{ parameters.testName }}.binlog -c ${{ parameters.configuration }} --results-directory $resultsDir --report-trx --report-trx-filename ${{ parameters.testName }}.trx --output Detailed ${{ parameters.extraBuildArgs }}
Pop-Location
displayName: run ${{ parameters.testName }}
Expand Down Expand Up @@ -59,13 +57,20 @@ steps:
continueOnError: true
timeoutInMinutes: 3

- script: >
DEST="$(Build.StagingDirectory)/Test${{ parameters.configuration }}/${{ parameters.artifactFolder }}/" &&
mkdir -p "$DEST" &&
cp "${{ parameters.artifactSource }}" "$DEST" ||
echo "copy apk/aab failed" # We don't need to report the error
displayName: copy apk/aab
condition: ne(variables['Agent.JobStatus'], 'Succeeded')
- script: |
DEST="$(Build.StagingDirectory)/Test${{ parameters.configuration }}/${{ parameters.artifactFolder }}/"
INTERMEDIATE_DIR="$(dirname "${{ parameters.project }}")/obj/${{ parameters.configuration }}/$(DotNetTargetFramework)-android/android/bin"
mkdir -p "$DEST"
cp "${{ parameters.artifactSource }}" "$DEST" || echo "copy apk/aab failed"
cp "$INTERMEDIATE_DIR/packaged_resources" "$DEST/packaged_resources.zip" || echo "copy packaged_resources failed"
cp "$INTERMEDIATE_DIR/base.zip" "$DEST" || echo "copy base.zip failed"
for AAB in "$INTERMEDIATE_DIR"/*.aab; do
if [ -f "$AAB" ]; then
cp "$AAB" "$DEST"
fi
done
displayName: copy package intermediates
condition: ${{ parameters.condition }}
continueOnError: true

# Always capture full device logcat so we can diagnose native library load
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,6 @@ stages:
artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab
artifactFolder: $(DotNetTargetFramework)-NativeAOT

- template: /build-tools/automation/yaml-templates/apk-instrumentation.yaml
parameters:
configuration: $(XA.Build.Configuration)
testName: Mono.Android.NET_Tests-NativeAOTTrimmable
project: tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj
extraBuildArgs: -p:TestsFlavor=NativeAOTTrimmable -p:PublishAot=true -p:_AndroidTypeMapImplementation=trimmable
artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab
artifactFolder: $(DotNetTargetFramework)-NativeAOTTrimmable

- template: /build-tools/automation/yaml-templates/apk-instrumentation.yaml
parameters:
configuration: $(XA.Build.Configuration)
Expand Down
32 changes: 16 additions & 16 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<Dependencies>
<ProductDependencies>
<Dependency Name="Microsoft.NET.Sdk" Version="11.0.100-rc.1.26401.101">
<Dependency Name="Microsoft.NET.Sdk" Version="11.0.100-rc.1.26411.119">
<Uri>https://github.com/dotnet/dotnet</Uri>
<Sha>5da2de22f7c6e2ebe7ed4c16c614b00183145d3c</Sha>
<Sha>7cdb217445905f3342bbb0266a4497b9a014389a</Sha>
</Dependency>
<Dependency Name="Microsoft.NET.ILLink" Version="11.0.0-rc.1.26401.101">
<Dependency Name="Microsoft.NET.ILLink" Version="11.0.0-rc.1.26411.119">
<Uri>https://github.com/dotnet/dotnet</Uri>
<Sha>5da2de22f7c6e2ebe7ed4c16c614b00183145d3c</Sha>
<Sha>7cdb217445905f3342bbb0266a4497b9a014389a</Sha>
</Dependency>
<Dependency Name="Microsoft.NETCore.App.Ref" Version="11.0.0-rc.1.26401.101">
<Dependency Name="Microsoft.NETCore.App.Ref" Version="11.0.0-rc.1.26411.119">
<Uri>https://github.com/dotnet/dotnet</Uri>
<Sha>5da2de22f7c6e2ebe7ed4c16c614b00183145d3c</Sha>
<Sha>7cdb217445905f3342bbb0266a4497b9a014389a</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Cecil" Version="0.11.5-preview.26401.101">
<Dependency Name="Microsoft.DotNet.Cecil" Version="0.11.5-preview.26411.119">
<Uri>https://github.com/dotnet/dotnet</Uri>
<Sha>5da2de22f7c6e2ebe7ed4c16c614b00183145d3c</Sha>
<Sha>7cdb217445905f3342bbb0266a4497b9a014389a</Sha>
</Dependency>
<Dependency Name="Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest-11.0.100-preview.4" Version="11.0.100-preview.4.26215.121">
<Uri>https://github.com/dotnet/dotnet</Uri>
Expand All @@ -36,21 +36,21 @@
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="11.0.0-beta.26401.101">
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="11.0.0-beta.26411.119">
<Uri>https://github.com/dotnet/dotnet</Uri>
<Sha>5da2de22f7c6e2ebe7ed4c16c614b00183145d3c</Sha>
<Sha>7cdb217445905f3342bbb0266a4497b9a014389a</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Build.Tasks.Feed" Version="11.0.0-beta.26401.101">
<Dependency Name="Microsoft.DotNet.Build.Tasks.Feed" Version="11.0.0-beta.26411.119">
<Uri>https://github.com/dotnet/dotnet</Uri>
<Sha>5da2de22f7c6e2ebe7ed4c16c614b00183145d3c</Sha>
<Sha>7cdb217445905f3342bbb0266a4497b9a014389a</Sha>
</Dependency>
<Dependency Name="Microsoft.TemplateEngine.Authoring.Tasks" Version="11.0.100-rc.1.26401.101">
<Dependency Name="Microsoft.TemplateEngine.Authoring.Tasks" Version="11.0.100-rc.1.26411.119">
<Uri>https://github.com/dotnet/dotnet</Uri>
<Sha>5da2de22f7c6e2ebe7ed4c16c614b00183145d3c</Sha>
<Sha>7cdb217445905f3342bbb0266a4497b9a014389a</Sha>
</Dependency>
<Dependency Name="MSTest" Version="4.4.0-preview.26402.3">
<Dependency Name="MSTest" Version="4.4.0-preview.26409.6">
<Uri>https://github.com/microsoft/testfx</Uri>
<Sha>e492730d840fc5864eff04230dd993041cf6189a</Sha>
<Sha>26dda6f3c287c9f8a012c2727870d33a0d88e0cb</Sha>
</Dependency>
</ToolsetDependencies>
</Dependencies>
14 changes: 7 additions & 7 deletions eng/Versions.props
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<Project>
<!--Package versions-->
<PropertyGroup>
<MicrosoftNETSdkPackageVersion>11.0.100-rc.1.26401.101</MicrosoftNETSdkPackageVersion>
<MicrosoftNETSdkPackageVersion>11.0.100-rc.1.26411.119</MicrosoftNETSdkPackageVersion>
<MicrosoftDotnetSdkInternalPackageVersion>$(MicrosoftNETSdkPackageVersion)</MicrosoftDotnetSdkInternalPackageVersion>
<MicrosoftNETILLinkPackageVersion>11.0.0-rc.1.26401.101</MicrosoftNETILLinkPackageVersion>
<MicrosoftNETCoreAppRefPackageVersion>11.0.0-rc.1.26401.101</MicrosoftNETCoreAppRefPackageVersion>
<MicrosoftNETILLinkPackageVersion>11.0.0-rc.1.26411.119</MicrosoftNETILLinkPackageVersion>
<MicrosoftNETCoreAppRefPackageVersion>11.0.0-rc.1.26411.119</MicrosoftNETCoreAppRefPackageVersion>
<MicrosoftDotNetApiCompatPackageVersion>7.0.0-beta.22103.1</MicrosoftDotNetApiCompatPackageVersion>
<!-- Last version built for net10.0, needed for CI steps that only have the .NET 10 SDK installed (e.g., BAR manifest publishing) -->
<MicrosoftDotNetBuildTasksFeedPackageVersionNet10>11.0.0-beta.26060.102</MicrosoftDotNetBuildTasksFeedPackageVersionNet10>
<MicrosoftDotNetBuildTasksFeedPackageVersion>11.0.0-beta.26401.101</MicrosoftDotNetBuildTasksFeedPackageVersion>
<MicrosoftDotNetBuildTasksFeedPackageVersion>11.0.0-beta.26411.119</MicrosoftDotNetBuildTasksFeedPackageVersion>
<MicrosoftNETWorkloadMonoToolchainCurrentManifest110100preview4PackageVersion>11.0.100-preview.4.26215.121</MicrosoftNETWorkloadMonoToolchainCurrentManifest110100preview4PackageVersion>
<MicrosoftNETWorkloadEmscriptenCurrentManifest110100preview4PackageVersion>11.0.100-preview.4.26215.121</MicrosoftNETWorkloadEmscriptenCurrentManifest110100preview4PackageVersion>
<MicrosoftNETWorkloadMonoToolChainPackageVersion>$(MicrosoftNETWorkloadMonoToolChainCurrentManifest110100preview4PackageVersion)</MicrosoftNETWorkloadMonoToolChainPackageVersion>
<MicrosoftNETWorkloadEmscriptenPackageVersion>$(MicrosoftNETWorkloadEmscriptenCurrentManifest110100preview4PackageVersion)</MicrosoftNETWorkloadEmscriptenPackageVersion>
<MicrosoftTemplateEngineAuthoringTasksPackageVersion>11.0.100-rc.1.26401.101</MicrosoftTemplateEngineAuthoringTasksPackageVersion>
<MicrosoftDotNetCecilPackageVersion>0.11.5-preview.26401.101</MicrosoftDotNetCecilPackageVersion>
<MSTestPackageVersion>4.4.0-preview.26402.3</MSTestPackageVersion>
<MicrosoftTemplateEngineAuthoringTasksPackageVersion>11.0.100-rc.1.26411.119</MicrosoftTemplateEngineAuthoringTasksPackageVersion>
<MicrosoftDotNetCecilPackageVersion>0.11.5-preview.26411.119</MicrosoftDotNetCecilPackageVersion>
<MSTestPackageVersion>4.4.0-preview.26409.6</MSTestPackageVersion>
<SystemIOHashingPackageVersion>10.0.10</SystemIOHashingPackageVersion>
<SystemReflectionMetadataPackageVersion>11.0.0-preview.1.26104.118</SystemReflectionMetadataPackageVersion>
<!-- Previous .NET Android version -->
Expand Down
154 changes: 154 additions & 0 deletions eng/common/Get-GitHubAppToken.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
# Mints a short-lived GitHub App installation access token by signing a JWT
# with a private key stored in Azure Key Vault (RSA, RS256). The signed JWT is
# exchanged with the GitHub API for a token scoped to a single installation.
#
# Requirements:
# - A GitHub App whose private key has been uploaded into Key Vault as an RSA
# key (the PEM converted to a Key Vault *key*, NOT stored as a secret).
# - The caller (the federated Azure service connection used to run this script)
# must have the `Key Vault Crypto User` role (or at minimum the `Sign`
# action) on that key.
# - The App must be installed on the target organization/account
# (`InstallationOwner`) with the permissions/repositories it needs.
#
# Installation tokens (ghs_*) are exempt from the enterprise classic-PAT
# lifetime policy, which is why this replaces the long-lived PAT.

[CmdletBinding()]
param(
# Name of the Key Vault that holds the GitHub App's RSA signing key.
[Parameter(Mandatory = $true)]
[string] $KeyVaultName,

# Name of the RSA key inside the Key Vault (the App's private key).
[Parameter(Mandatory = $true)]
[string] $KeyName,

# The GitHub App's Client ID (the value to put in the `iss` JWT claim).
[Parameter(Mandatory = $true)]
[string] $AppClientId,

# Login of the organization or user account whose installation we should
# mint the token for (e.g. `dotnet`, `microsoft`).
[Parameter(Mandatory = $true)]
[string] $InstallationOwner,

# Optional Azure DevOps pipeline variable name to set with the installation
# token (marked as a secret). When not specified, the token is written to
# stdout instead.
[Parameter(Mandatory = $false)]
[string] $OutputVariableName
)

$ErrorActionPreference = 'Stop'
$PSNativeCommandUseErrorActionPreference = $true

. $PSScriptRoot\pipeline-logging-functions.ps1

function ConvertTo-Base64Url([byte[]] $bytes) {
return [Convert]::ToBase64String($bytes).TrimEnd('=').Replace('+', '-').Replace('/', '_')
}

# Build JWT header and payload. Use [ordered] hashtables so JSON
# serialization is deterministic.
$jwtHeader = [ordered]@{
alg = 'RS256'
typ = 'JWT'
}
$now = [System.DateTimeOffset]::UtcNow
$jwtPayload = [ordered]@{
iat = $now.AddMinutes(-1).ToUnixTimeSeconds()
exp = $now.AddMinutes(5).ToUnixTimeSeconds()
iss = $AppClientId
}

$headerEncoded = ConvertTo-Base64Url ([System.Text.Encoding]::UTF8.GetBytes(($jwtHeader | ConvertTo-Json -Compress)))
$payloadEncoded = ConvertTo-Base64Url ([System.Text.Encoding]::UTF8.GetBytes(($jwtPayload | ConvertTo-Json -Compress)))
$signingInput = "$headerEncoded.$payloadEncoded"

# Key Vault `sign` expects the *digest* (base64), not the raw bytes.
$sha256 = [System.Security.Cryptography.SHA256]::Create()
$digestBytes = $sha256.ComputeHash([System.Text.Encoding]::UTF8.GetBytes($signingInput))
$digestBase64 = [Convert]::ToBase64String($digestBytes)

Write-Host "Signing JWT with key '$KeyName' in vault '$KeyVaultName'..."
$previousNativeCommandErrorPreference = $PSNativeCommandUseErrorActionPreference
try {
# Azure CLI can emit non-fatal Python warnings to stderr even when signing succeeds.
# Use the exit code to determine success for this invocation.
$PSNativeCommandUseErrorActionPreference = $false
$signatureBase64 = az keyvault key sign `
--vault-name $KeyVaultName `
--name $KeyName `
--algorithm RS256 `
--digest $digestBase64 `
--query signature `
--output tsv `
--only-show-errors
$signExitCode = $LASTEXITCODE
}
catch {
Write-PipelineTelemetryError -Category 'Build' -Message "Failed to sign the JWT via Key Vault (key '$KeyName', vault '$KeyVaultName'): $_. Verify the service connection identity has the 'Key Vault Crypto User' role (Sign action) on the key."
exit 1
}
finally {
$PSNativeCommandUseErrorActionPreference = $previousNativeCommandErrorPreference
}
if ($signExitCode -ne 0 -or [string]::IsNullOrWhiteSpace($signatureBase64)) {
Write-PipelineTelemetryError -Category 'Build' -Message "'az keyvault key sign' exited with code $signExitCode for key '$KeyName' in vault '$KeyVaultName'. Verify the service connection identity has the 'Key Vault Crypto User' role (Sign action) on the key."
exit 1
}
$signatureUrl = $signatureBase64.Trim().TrimEnd('=').Replace('+', '-').Replace('/', '_')
$jwt = "$signingInput.$signatureUrl"

$headers = @{
Authorization = "Bearer $jwt"
'X-GitHub-Api-Version' = '2022-11-28'
Accept = 'application/vnd.github+json'
'User-Agent' = 'dotnet-arcade-onelocbuild'
}

Write-Host "Looking up installation for '$InstallationOwner'..."
try {
$installations = @()
$page = 1
do {
$pageInstallations = @(Invoke-RestMethod `
-Uri "https://api.github.com/app/installations?per_page=100&page=$page" `
-Headers $headers `
-Method Get)
$installations += $pageInstallations
$page++
} while ($pageInstallations.Count -eq 100)
}
catch {
Write-PipelineTelemetryError -Category 'Build' -Message "Failed to list GitHub App installations: $_. The signed JWT may be invalid or the App's Client ID ('$AppClientId') may be incorrect."
exit 1
}
$installation = $installations | Where-Object { $_.account.login -ieq $InstallationOwner } | Select-Object -First 1
if (-not $installation) {
$found = ($installations | ForEach-Object { $_.account.login }) -join ', '
Write-PipelineTelemetryError -Category 'Build' -Message "No installation found for '$InstallationOwner'. App is installed on: $found"
exit 1
}

try {
$tokenResponse = Invoke-RestMethod `
-Uri "https://api.github.com/app/installations/$($installation.id)/access_tokens" `
-Headers $headers `
-Method Post `
-ContentType 'application/json'
}
catch {
Write-PipelineTelemetryError -Category 'Build' -Message "Failed to mint an installation access token for '$InstallationOwner' (installation $($installation.id)): $_"
exit 1
}

Write-Host "Got installation token for '$InstallationOwner' (expires $($tokenResponse.expires_at))."
if ($OutputVariableName) {
Write-Host "Setting pipeline variable '$OutputVariableName'."
Write-Host "##vso[task.setvariable variable=$OutputVariableName;issecret=true]$($tokenResponse.token)"
}
else {
Write-Host $tokenResponse.token -ForegroundColor Green
}
Loading
Loading