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
2451if ($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.' }
3057if ($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