diff --git a/eng/DependencyManagement.psm1 b/eng/DependencyManagement.psm1 new file mode 100644 index 000000000..8f9746c20 --- /dev/null +++ b/eng/DependencyManagement.psm1 @@ -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 +} diff --git a/eng/Get-AspireDropVersions.ps1 b/eng/Get-AspireDropVersions.ps1 new file mode 100644 index 000000000..e1bcaf702 --- /dev/null +++ b/eng/Get-AspireDropVersions.ps1 @@ -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" diff --git a/eng/Get-Branch.ps1 b/eng/Get-Branch.ps1 deleted file mode 100644 index 252186efb..000000000 --- a/eng/Get-Branch.ps1 +++ /dev/null @@ -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" -} diff --git a/eng/Get-DropVersions.ps1 b/eng/Get-DropVersions.ps1 index 9ceabb0cc..3f2e0d261 100644 --- a/eng/Get-DropVersions.ps1 +++ b/eng/Get-DropVersions.ps1 @@ -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 diff --git a/eng/Get-IsStableBranding.ps1 b/eng/Get-IsStableBranding.ps1 deleted file mode 100644 index c0a7d0309..000000000 --- a/eng/Get-IsStableBranding.ps1 +++ /dev/null @@ -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 diff --git a/eng/Get-MonitorDropVersions.ps1 b/eng/Get-MonitorDropVersions.ps1 index 86caf1c55..3fcb7630e 100644 --- a/eng/Get-MonitorDropVersions.ps1 +++ b/eng/Get-MonitorDropVersions.ps1 @@ -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" diff --git a/eng/Set-DotnetVersions.ps1 b/eng/Set-DotnetVersions.ps1 index aea3e0db9..c95ca8aa3 100644 --- a/eng/Set-DotnetVersions.ps1 +++ b/eng/Set-DotnetVersions.ps1 @@ -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" diff --git a/eng/dockerfile-templates/Get-GeneratedDockerfiles.ps1 b/eng/dockerfile-templates/Get-GeneratedDockerfiles.ps1 index 6cb3b1b61..3161bc45f 100644 --- a/eng/dockerfile-templates/Get-GeneratedDockerfiles.ps1 +++ b/eng/dockerfile-templates/Get-GeneratedDockerfiles.ps1 @@ -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 ` diff --git a/eng/dockerfile-templates/aspire-dashboard/Dockerfile.linux.install-aspire-dashboard b/eng/dockerfile-templates/aspire-dashboard/Dockerfile.linux.install-aspire-dashboard index f10bb132c..cf57b9b0c 100644 --- a/eng/dockerfile-templates/aspire-dashboard/Dockerfile.linux.install-aspire-dashboard +++ b/eng/dockerfile-templates/aspire-dashboard/Dockerfile.linux.install-aspire-dashboard @@ -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}} \ diff --git a/eng/pipelines/steps/update-dotnet-dependencies.yml b/eng/pipelines/steps/update-dotnet-dependencies.yml index 1ec05fe2f..aa0028507 100644 --- a/eng/pipelines/steps/update-dotnet-dependencies.yml +++ b/eng/pipelines/steps/update-dotnet-dependencies.yml @@ -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 diff --git a/eng/readme-templates/Get-GeneratedReadmes.ps1 b/eng/readme-templates/Get-GeneratedReadmes.ps1 index 80f2ce9b0..fc9daca6d 100644 --- a/eng/readme-templates/Get-GeneratedReadmes.ps1 +++ b/eng/readme-templates/Get-GeneratedReadmes.ps1 @@ -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 diff --git a/eng/update-dependencies/DockerfileShaUpdater.cs b/eng/update-dependencies/DockerfileShaUpdater.cs index 74f80cec6..8a1578880 100644 --- a/eng/update-dependencies/DockerfileShaUpdater.cs +++ b/eng/update-dependencies/DockerfileShaUpdater.cs @@ -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 diff --git a/eng/update-dependencies/ManifestHelper.cs b/eng/update-dependencies/ManifestHelper.cs index 23cabdadf..763b774c4 100644 --- a/eng/update-dependencies/ManifestHelper.cs +++ b/eng/update-dependencies/ManifestHelper.cs @@ -31,9 +31,15 @@ public static class ManifestHelper /// /// Dockerfile version. /// Name of the branch. - 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}"; } diff --git a/manifest.versions.json b/manifest.versions.json index 1970f8449..1b0a34d6d 100644 --- a/manifest.versions.json +++ b/manifest.versions.json @@ -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)", diff --git a/src/aspire-dashboard/8.0/cbl-mariner-distroless/amd64/Dockerfile b/src/aspire-dashboard/8.0/cbl-mariner-distroless/amd64/Dockerfile index 87083c2a1..70d4cc794 100644 --- a/src/aspire-dashboard/8.0/cbl-mariner-distroless/amd64/Dockerfile +++ b/src/aspire-dashboard/8.0/cbl-mariner-distroless/amd64/Dockerfile @@ -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 diff --git a/src/aspire-dashboard/8.0/cbl-mariner-distroless/arm64v8/Dockerfile b/src/aspire-dashboard/8.0/cbl-mariner-distroless/arm64v8/Dockerfile index bc8057462..87635461a 100644 --- a/src/aspire-dashboard/8.0/cbl-mariner-distroless/arm64v8/Dockerfile +++ b/src/aspire-dashboard/8.0/cbl-mariner-distroless/arm64v8/Dockerfile @@ -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 diff --git a/tests/run-tests.ps1 b/tests/run-tests.ps1 index 67ddbec68..15fddbf34 100644 --- a/tests/run-tests.ps1 +++ b/tests/run-tests.ps1 @@ -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"