Skip to content

Commit bb7fc8d

Browse files
committed
Fix SDK 10 native tool verification on macOS ARM64
1 parent 0d4d6dd commit bb7fc8d

3 files changed

Lines changed: 33 additions & 8 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
if: matrix.rid != 'win-arm64'
6565
run: |
6666
$version = ([xml](Get-Content src/Tonarink.Cli/Tonarink.Cli.csproj -Raw)).Project.PropertyGroup.Version
67-
./tools/Verify-CliTool.ps1 -AssetDirectory artifacts/cli/nuget -Version $version -InstallerSdkVersion '${{ steps.installer-sdk.outputs.dotnet-version }}'
67+
./tools/Verify-CliTool.ps1 -AssetDirectory artifacts/cli/nuget -Version $version -InstallerSdkVersion '${{ steps.installer-sdk.outputs.dotnet-version }}' -RuntimeIdentifier '${{ matrix.rid }}'
6868
6969
ui:
7070
runs-on: windows-latest

‎.github/workflows/release-cli.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ jobs:
123123
run: |
124124
Copy-Item artifacts/cli/native/*.nupkg artifacts/cli/verify
125125
Copy-Item artifacts/cli/native/tonarink-cli-* artifacts/cli/verify
126-
./tools/Verify-CliTool.ps1 -AssetDirectory artifacts/cli/verify -Version '${{ needs.version.outputs.version }}' -InstallerSdkVersion '${{ steps.installer-sdk.outputs.dotnet-version }}'
126+
./tools/Verify-CliTool.ps1 -AssetDirectory artifacts/cli/verify -Version '${{ needs.version.outputs.version }}' -InstallerSdkVersion '${{ steps.installer-sdk.outputs.dotnet-version }}' -RuntimeIdentifier '${{ matrix.rid }}'
127127
- uses: actions/upload-artifact@v4
128128
with:
129129
name: cli-native-${{ matrix.rid }}

‎tools/Verify-CliTool.ps1‎

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ param(
66
[Parameter(Mandatory)]
77
[string]$Version,
88
[Parameter(Mandatory)]
9-
[string]$InstallerSdkVersion
9+
[string]$InstallerSdkVersion,
10+
[Parameter(Mandatory)]
11+
[ValidateSet('win-x64', 'win-arm64', 'linux-x64', 'linux-arm64', 'osx-x64', 'osx-arm64')]
12+
[string]$RuntimeIdentifier
1013
)
1114

1215
$ErrorActionPreference = 'Stop'
@@ -17,10 +20,34 @@ $profile = Join-Path $work 'profile'
1720
$config = Join-Path $work 'NuGet.Config'
1821
$assetRoot = (Resolve-Path -LiteralPath $AssetDirectory).Path
1922
$feed = [Security.SecurityElement]::Escape($assetRoot)
20-
# Only local artifacts can satisfy this install, never an older published version.
21-
Set-Content -LiteralPath $config -Value "<configuration><packageSources><clear/><add key=`"cli-build`" value=`"$feed`" /></packageSources></configuration>"
23+
# Only local artifacts can satisfy the CLI install, never a published version.
24+
# SDK 10 still resolves a legacy apphost template for tools/any on macOS ARM64
25+
# before creating the native executable launcher. Allow only that SDK support
26+
# package from NuGet.org; the CLI and every RID package must come from this build.
27+
Set-Content -LiteralPath $config -Value @"
28+
<configuration>
29+
<packageSources>
30+
<clear />
31+
<add key="cli-build" value="$feed" />
32+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
33+
</packageSources>
34+
<packageSourceMapping>
35+
<clear />
36+
<packageSource key="cli-build">
37+
<package pattern="tonarink-cli" />
38+
<package pattern="tonarink-cli.*" />
39+
</packageSource>
40+
<packageSource key="nuget.org">
41+
<package pattern="Microsoft.NETCore.App.Host.*" />
42+
</packageSource>
43+
</packageSourceMapping>
44+
</configuration>
45+
"@
2246
$sdkCli = Join-Path $env:DOTNET_ROOT "sdk/$InstallerSdkVersion/dotnet.dll"
23-
dotnet exec $sdkCli tool install tonarink-cli --tool-path $toolDirectory --version $Version --configfile $config --no-cache
47+
$dotnetHost = Join-Path $env:DOTNET_ROOT $(if ($IsWindows) { 'dotnet.exe' } else { 'dotnet' })
48+
$hostOS, $architecture = $RuntimeIdentifier.Split('-')
49+
# Use the selected SDK installation's host, rather than another dotnet on PATH.
50+
& $dotnetHost exec $sdkCli tool install tonarink-cli --tool-path $toolDirectory --version $Version --configfile $config --no-cache
2451
if ($LASTEXITCODE -ne 0) { throw 'AOT tool installation failed.' }
2552
# Native tools use a .cmd launcher on Windows and an executable launcher on Unix.
2653
$cli = Join-Path $toolDirectory 'tonarink-cli'
@@ -30,8 +57,6 @@ if ($LASTEXITCODE -ne 0) { throw 'Tool help failed.' }
3057
if ($LASTEXITCODE -ne 0) { throw 'Localized tool help failed.' }
3158
# Check the distributed archive, not only the staging binary. On Unix this also
3259
# catches a lost executable bit: deliberately do not chmod after extraction.
33-
$hostOS = if ($IsWindows) { 'win' } elseif ($IsMacOS) { 'osx' } else { 'linux' }
34-
$architecture = [Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLowerInvariant()
3560
$archiveExtension = if ($IsWindows) { 'zip' } else { 'tar.gz' }
3661
$archive = Join-Path $assetRoot "tonarink-cli-$Version-$hostOS-$architecture.$archiveExtension"
3762
$portableDirectory = Join-Path $work 'portable'

0 commit comments

Comments
 (0)