Add Aspire Dashboard support to update-dependencies tooling (#5179)

This commit is contained in:
Logan Bussell 2024-02-08 18:05:00 -08:00
Родитель f18313c6b9
Коммит cdd14b5ce9
17 изменённых файлов: 139 добавлений и 64 удалений

Просмотреть файл

@ -0,0 +1,27 @@
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version 2.0
# Common functions for .NET Docker dependency management
function Get-Branch() {
$repoRoot = (Get-Item "$PSScriptRoot").Parent.FullName
$manifestJson = Get-Content ${repoRoot}/manifest.json | ConvertFrom-Json
if ($manifestJson.Repos[0].Name.Contains("nightly")) {
return "nightly"
}
else {
return "main"
}
}
function Get-IsStableBranding([string] $version) {
return $Version.Contains("-servicing") -or $Version.Contains("-rtm")
}
function Resolve-DotnetProductUrl([string] $akaMsUrl) {
Write-Host "Querying $akaMsUrl"
$response = Invoke-WebRequest -Uri $akaMsUrl -Method Head
$resolvedUrl = $response.BaseResponse.RequestMessage.RequestUri.AbsoluteUri
Write-Host "Resolved URL: $resolvedUrl"
return $resolvedUrl
}

Просмотреть файл

@ -0,0 +1,42 @@
<#
.SYNOPSIS
Returns the various component versions of the latest .NET build.
#>
[cmdletbinding()]
param(
# The release channel to use for determining the latest .NET build.
[Parameter(ParameterSetName = "Channel")]
[string]
$Channel,
[Parameter(ParameterSetName = "Explicit")]
# Aspire version to target
[string]
$AspireVersion
)
$ErrorActionPreference = 'Stop'
Import-Module -force $PSScriptRoot/DependencyManagement.psm1
if ($Channel) {
# Example channel: '8.0/daily'
$akaMsUrl = "https://aka.ms/dotnet/${Channel}/aspire-dashboard-linux-x64.zip"
$versionSpecificUrl = Resolve-DotnetProductUrl $akaMsUrl
# Assume the versionSpecificUrl is a string like
# https://dotnetbuilds.azureedge.net/public/aspire/8.0.0-preview.X.YYYYY.Z/aspire-dashboard-linux-x64.zip
$aspireVersion = $versionSpecificUrl -replace '^.*/aspire/([^/]+)/.*$', '$1'
if (Get-IsStableBranding $aspireVersion) {
# The stable version for 8.0.0-preview.4.24105.1 is 8.0.0-preview.4
$aspireVersion = $aspireVersion -replace '^(.*?)-.*$', '$1'
}
} else {
$aspireVersion = $AspireVersion
}
# Grab the major.minor version from the Aspire version string
$dockerfileVersion = $aspireVersion -replace '^(\d+\.\d+).*$', '$1'
Write-Output "##vso[task.setvariable variable=dockerfileVersion]$dockerfileVersion"
Write-Output "##vso[task.setvariable variable=aspireVersion]$aspireVersion"

Просмотреть файл

@ -1,10 +0,0 @@
#!/usr/bin/env pwsh
$repoRoot = (Get-Item "$PSScriptRoot").Parent.FullName
$manifestJson = Get-Content ${repoRoot}/manifest.json | ConvertFrom-Json
if ($manifestJson.Repos[0].Name.Contains("nightly")) {
return "nightly"
}
else {
return "main"
}

Просмотреть файл

@ -29,16 +29,7 @@ param(
$AzdoVersionsRepoInfoAccessToken
)
function GetLatestSdkVersionInfoFromChannel([string]$queryString) {
$sdkFile = "dotnet-sdk-win-x64.zip"
$akaMsUrl = "https://aka.ms/dotnet/$Channel/$sdkFile$queryString"
Write-Host "Querying $akaMsUrl"
$response = Invoke-WebRequest -Uri $akaMsUrl -Method Head
$sdkUrl = $response.BaseResponse.RequestMessage.RequestUri.AbsoluteUri
Write-Host "Resolved SDK URL: $sdkUrl"
return GetSdkVersionInfo $sdkUrl
}
Import-Module -force $PSScriptRoot/DependencyManagement.psm1
function GetSdkVersionInfo([string]$sdkUrl) {
New-Item -Path $tempDir -ItemType Directory -Force | Out-Null
@ -162,13 +153,16 @@ else {
$sdkVersionInfos = @()
if ($Channel) {
$sdkVersionInfo = GetLatestSdkVersionInfoFromChannel $queryString
$sdkVersionInfos += $sdkVersionInfo
$sdkFile = "dotnet-sdk-win-x64.zip"
$akaMsUrl = "https://aka.ms/dotnet/$Channel/$sdkFile$queryString"
$sdkUrl = Resolve-DotnetProductUrl $akaMsUrl
$sdkVersionInfos += GetSdkVersionInfo $sdkUrl
}
foreach ($sdkVersion in $SdkVersions)
{
$useStableBranding = & $PSScriptRoot/Get-IsStableBranding.ps1 -Version $sdkVersion
$useStableBranding = Get-IsStableBranding -Version $sdkVersion
$sdkUrl = ResolveSdkUrl $sdkVersion $queryString $useStableBranding
$sdkVersionInfo = GetSdkVersionInfo $sdkUrl
$sdkVersionInfos += $sdkVersionInfo

Просмотреть файл

@ -1,22 +0,0 @@
#!/usr/bin/env pwsh
<#
.SYNOPSIS
Returns a value indicating whether the specified version is associated with stable branding.
#>
[cmdletbinding()]
param(
# Build version of the product
[string]
$Version
)
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version 2.0
if ($Version.Contains("-servicing") -or $Version.Contains("-rtm")) {
return $true
}
return $false

Просмотреть файл

@ -13,12 +13,14 @@ param(
$BuildVersionFilePath
)
Import-Module -force $PSScriptRoot/DependencyManagement.psm1
$monitorVersion = $(Get-Content $BuildVersionFilePath).Trim()
$versionSplit=$monitorVersion.Split('.', 3)
$majorMinorVersion="$($versionSplit[0]).$($versionSplit[1])"
$stableBranding = & $PSScriptRoot/Get-IsStableBranding.ps1 -Version $monitorVersion
$stableBranding = Get-IsStableBranding -Version $monitorVersion
Write-Output "##vso[task.setvariable variable=monitorMajorMinorVersion]$majorMinorVersion"
Write-Output "##vso[task.setvariable variable=monitorVer]$monitorVersion"

Просмотреть файл

@ -31,6 +31,11 @@ param(
[string]
$MonitorVersion,
# Build verison of the .NET Aspire Dashboard
[Parameter(Mandatory = $false, ParameterSetName = 'DotnetAspireDashboard')]
[string]
$AspireVersion,
# Compute the checksum if a published checksum cannot be found
[Switch]
$ComputeShas,
@ -56,6 +61,8 @@ param(
$ChecksumsFile
)
Import-Module -force $PSScriptRoot/DependencyManagement.psm1
$updateDepsArgs = @($ProductVersion)
if ($SdkVersion) {
@ -81,6 +88,11 @@ if ($MonitorVersion) {
}
}
if ($AspireVersion) {
$updateDepsArgs += @("--product-version", "aspire-dashboard=$AspireVersion")
$productMajorVersion = $ProductVersion.Split('.', 2)[0]
}
if ($ComputeShas) {
$updateDepsArgs += "--compute-shas"
}
@ -104,6 +116,7 @@ if ($UseStableBranding) {
$versionSourceName = switch ($PSCmdlet.ParameterSetName) {
"DotnetInstaller" { "dotnet/installer" }
"DotnetMonitor" { "dotnet/dotnet-monitor/$ProductVersion" }
"DotnetAspireDashboard" { "dotnet/aspire-dashboard/$ProductVersion" }
default { Write-Error -Message "Unknown version source" -ErrorAction Stop }
}
@ -111,8 +124,7 @@ if ($versionSourceName) {
$updateDepsArgs += "--version-source-name=$versionSourceName"
}
$branch = & $PSScriptRoot/Get-Branch.ps1
$updateDepsArgs += "--source-branch=$branch"
$updateDepsArgs += "--source-branch=$(Get-Branch)"
if ($AzdoVariableName) {
Write-Host "##vso[task.setvariable variable=$AzdoVariableName]$updateDepsArgs"

Просмотреть файл

@ -4,6 +4,8 @@ param(
[string]$Branch
)
Import-Module -force $PSScriptRoot/../DependencyManagement.psm1
if ($Validate) {
$customImageBuilderArgs = " --validate"
}
@ -19,7 +21,7 @@ $onDockerfilesGenerated = {
}
if (!$Branch) {
$Branch = & $PSScriptRoot/../Get-Branch.ps1
$Branch = Get-Branch
}
& $PSScriptRoot/../common/Invoke-ImageBuilder.ps1 `

Просмотреть файл

@ -10,8 +10,10 @@
set aspireBaseUrl to cat(VARIABLES[cat("base-url|", aspireMajorMinor, "-aspire-dashboard|", urlBranch)], "/aspire/", versionFolder, "/") ^
set files to [
[
"filename": "dotnet-aspire.zip",
"url": cat(aspireBaseUrl, "aspire-dashboard-linux-", ARCH_SHORT, ".zip")
"filename": "aspire_dashboard.zip",
"url": cat(aspireBaseUrl, "aspire-dashboard-linux-", ARCH_SHORT, ".zip"),
"sha": VARIABLES[join(["aspire-dashboard", aspireMajorMinor, "linux", ARCH_SHORT, "sha"], "|")],
"sha-var-name": "aspire_dashboard_sha512"
]
]
}}RUN dotnet_aspire_version={{aspireVersion}} \

Просмотреть файл

@ -51,11 +51,13 @@ steps:
}
displayName: Get update-dependencies args
- powershell: |
Import-Module -force $(engPath)/DependencyManagement.psm1
$branchPrefix = ""
if ("${{ parameters.useInternalBuild }}" -eq "true") {
$branchPrefix = "internal/release/"
}
$targetBranch = $branchPrefix + $(& $(engPath)/Get-Branch.ps1)
$targetBranch = $branchPrefix + Get-Branch
$customArgsArray = @()
$index=0
@ -68,7 +70,7 @@ steps:
$customArgsArray += $updateDepsArgs
$index++
}
echo "##vso[task.setvariable variable=customArgsArray]$($customArgsArray | ConvertTo-Json -Compress -AsArray)"
displayName: Set Custom Args
- template: update-dependencies.yml

Просмотреть файл

@ -5,6 +5,7 @@ param(
)
$ErrorActionPreference = 'Stop'
Import-Module -force $PSScriptRoot/../DependencyManagement.psm1
if ($Validate) {
$customImageBuilderArgs = " --validate"
@ -52,7 +53,7 @@ function Invoke-GenerateReadme {
}
if (!$Branch) {
$Branch = & $PSScriptRoot/../Get-Branch.ps1
$Branch = Get-Branch
}
Invoke-GenerateReadme "manifest.json" $Branch

Просмотреть файл

@ -70,6 +70,8 @@ namespace Dotnet.Docker
{ "monitor-ext-azureblobstorage", new string[] { $"$DOTNET_BASE_URL/diagnostics/monitor/$VERSION_DIR/dotnet-monitor-egress-azureblobstorage-$VERSION_FILE-$OS-$ARCH.$ARCHIVE_EXT" } },
{ "monitor-ext-s3storage", new string[] { $"$DOTNET_BASE_URL/diagnostics/monitor/$VERSION_DIR/dotnet-monitor-egress-s3storage-$VERSION_FILE-$OS-$ARCH.$ARCHIVE_EXT" } },
{ "aspire-dashboard", [ $"$DOTNET_BASE_URL/aspire/$VERSION_DIR/aspire-dashboard-$OS-$ARCH.$ARCHIVE_EXT" ] },
{ "runtime", new string[] { $"$DOTNET_BASE_URL/Runtime/$VERSION_DIR/dotnet-runtime-$VERSION_FILE$OPTIONAL_OS-{GetRuntimeSdkArchFormat()}.$ARCHIVE_EXT" } },
{ "runtime-host", new string[] { $"$DOTNET_BASE_URL/Runtime/$VERSION_DIR/dotnet-host-$VERSION_FILE-{GetRpmArchFormat()}.$ARCHIVE_EXT" } },
{ "runtime-hostfxr", new string[] { $"$DOTNET_BASE_URL/Runtime/$VERSION_DIR/dotnet-hostfxr-$VERSION_FILE-{GetRpmArchFormat()}.$ARCHIVE_EXT" } },
@ -195,6 +197,13 @@ namespace Dotnet.Docker
archiveExt = "tar.gz";
}
// Special case for Aspire Dashboard
// Remove once https://github.com/dotnet/aspire/issues/2035 is fixed.
if (_productName.Contains("aspire-dashboard"))
{
archiveExt = "zip";
}
string optionalOs = _os.Contains("rpm") ? string.Empty : $"-{_os}";
// Each product name has one or more candidate URLs from which to retrieve the artifact. Multiple candidate URLs

Просмотреть файл

@ -31,9 +31,15 @@ public static class ManifestHelper
/// </summary>
/// <param name="dockerfileVersion">Dockerfile version.</param>
/// <param name="branch">Name of the branch.</param>
public static string GetBaseUrlVariableName(string dockerfileVersion, string branch, string versionSourceName)
public static string GetBaseUrlVariableName(string dockerfileVersion, string branch, string? versionSourceName)
{
string version = versionSourceName?.Contains("dotnet-monitor") == true ? $"{dockerfileVersion}-monitor" : dockerfileVersion;
string version = versionSourceName switch
{
string v when v.Contains("dotnet-monitor") => $"{dockerfileVersion}-monitor",
string v when v.Contains("aspire-dashboard") => $"{dockerfileVersion}-aspire-dashboard",
_ => dockerfileVersion,
};
return $"base-url|{version}|{branch}";
}

Просмотреть файл

@ -4,6 +4,8 @@
"aspire-dashboard|8.0|product-version": "8.0.0-preview.3",
"aspire-dashboard|8.0|fixed-tag": "$(aspire-dashboard|8.0|product-version)",
"aspire-dashboard|8.0|floating-tag": "8.0-preview",
"aspire-dashboard|8.0|linux|x64|sha": "fe8e7a4e921f6799793709996d5e8eb4eb921856e85b9ee8c6e6d28ab52ce608616a9a2ee36a59021b394b056d216d0af92288f03c355063c8e957bbc35cc95c",
"aspire-dashboard|8.0|linux|arm64|sha": "d56d60b141253527cd9591d091c8958aa96700d2df7a596da2391324e406a6e3ad25862d892ba3e19786e9ded26cb6516adaaef78b82ce500868a8e55d50c00c",
"aspnet|6.0|build-version": "6.0.28",
"aspnet|6.0|targeting-pack-version": "$(aspnet|6.0|build-version)",

Просмотреть файл

@ -10,10 +10,12 @@ RUN tdnf install -y \
# Retrieve Aspire Dashboard
RUN dotnet_aspire_version=8.0.0-preview.3.24075.10 \
&& curl -fSL --output dotnet-aspire.zip https://dotnetbuilds.azureedge.net/public/aspire/$dotnet_aspire_version/aspire-dashboard-linux-x64.zip \
&& curl -fSL --output aspire_dashboard.zip https://dotnetbuilds.azureedge.net/public/aspire/$dotnet_aspire_version/aspire-dashboard-linux-x64.zip \
&& aspire_dashboard_sha512='fe8e7a4e921f6799793709996d5e8eb4eb921856e85b9ee8c6e6d28ab52ce608616a9a2ee36a59021b394b056d216d0af92288f03c355063c8e957bbc35cc95c' \
&& echo "$aspire_dashboard_sha512 aspire_dashboard.zip" | sha512sum -c - \
&& mkdir -p /app \
&& unzip dotnet-aspire.zip -d /app \
&& rm dotnet-aspire.zip
&& unzip aspire_dashboard.zip -d /app \
&& rm aspire_dashboard.zip
# Aspire Dashboard image

Просмотреть файл

@ -10,10 +10,12 @@ RUN tdnf install -y \
# Retrieve Aspire Dashboard
RUN dotnet_aspire_version=8.0.0-preview.3.24075.10 \
&& curl -fSL --output dotnet-aspire.zip https://dotnetbuilds.azureedge.net/public/aspire/$dotnet_aspire_version/aspire-dashboard-linux-arm64.zip \
&& curl -fSL --output aspire_dashboard.zip https://dotnetbuilds.azureedge.net/public/aspire/$dotnet_aspire_version/aspire-dashboard-linux-arm64.zip \
&& aspire_dashboard_sha512='d56d60b141253527cd9591d091c8958aa96700d2df7a596da2391324e406a6e3ad25862d892ba3e19786e9ded26cb6516adaaef78b82ce500868a8e55d50c00c' \
&& echo "$aspire_dashboard_sha512 aspire_dashboard.zip" | sha512sum -c - \
&& mkdir -p /app \
&& unzip dotnet-aspire.zip -d /app \
&& rm dotnet-aspire.zip
&& unzip aspire_dashboard.zip -d /app \
&& rm aspire_dashboard.zip
# Aspire Dashboard image

Просмотреть файл

@ -34,6 +34,8 @@ param(
[securestring]$NuGetFeedPassword
)
Import-Module -force $PSScriptRoot/../eng/DependencyManagement.psm1
function Log {
param ([string] $Message)
@ -112,7 +114,7 @@ Try {
$env:REPO_PREFIX = $RepoPrefix
$env:IMAGE_INFO_PATH = $ImageInfoPath
$env:SOURCE_REPO_ROOT = (Get-Item "$PSScriptRoot").Parent.FullName
$env:SOURCE_BRANCH = & $PSScriptRoot/../eng/Get-Branch.ps1
$env:SOURCE_BRANCH = Get-Branch
$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
@ -131,7 +133,7 @@ Try {
# Construct an expression that filters the test to each of the
# selected TestCategories (using an OR operator between each category).
# See https://docs.microsoft.com/en-us/dotnet/core/testing/selective-unit-tests
$TestCategories | foreach {
$TestCategories | ForEach-Object {
# Skip pre-build tests on Windows because of missing pre-reqs (https://github.com/dotnet/dotnet-docker/issues/2261)
if ($_ -eq "pre-build" -and $activeOS -eq "windows") {
Write-Warning "Skipping pre-build tests for Windows containers"