|
3 | 3 | <!-- CopilotCliVersion is imported from GitHub.Copilot.SDK.props (generated at SDK build time, packaged alongside) --> |
4 | 4 | <Import Project="$(MSBuildThisFileDirectory)GitHub.Copilot.SDK.props" Condition="'$(CopilotCliVersion)' == '' And Exists('$(MSBuildThisFileDirectory)GitHub.Copilot.SDK.props')" /> |
5 | 5 |
|
6 | | - <!-- Resolve RID: use explicit RuntimeIdentifier, or infer from current machine --> |
| 6 | + <!-- Resolve RID: honor explicit portable RuntimeIdentifier for cross-platform builds, |
| 7 | + fall back to OS/arch detection only when RuntimeIdentifier is not set --> |
7 | 8 | <PropertyGroup> |
8 | | - <_CopilotRid Condition="'$(RuntimeIdentifier)' != ''">$(RuntimeIdentifier)</_CopilotRid> |
9 | | - <_CopilotRid Condition="'$(_CopilotRid)' == '' And $([MSBuild]::IsOSPlatform('Windows')) And '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'X64'">win-x64</_CopilotRid> |
10 | | - <_CopilotRid Condition="'$(_CopilotRid)' == '' And $([MSBuild]::IsOSPlatform('Windows')) And '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'Arm64'">win-arm64</_CopilotRid> |
11 | | - <_CopilotRid Condition="'$(_CopilotRid)' == '' And $([MSBuild]::IsOSPlatform('Linux')) And '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'X64'">linux-x64</_CopilotRid> |
12 | | - <_CopilotRid Condition="'$(_CopilotRid)' == '' And $([MSBuild]::IsOSPlatform('Linux')) And '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'Arm64'">linux-arm64</_CopilotRid> |
13 | | - <_CopilotRid Condition="'$(_CopilotRid)' == '' And $([MSBuild]::IsOSPlatform('OSX')) And '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'X64'">osx-x64</_CopilotRid> |
14 | | - <_CopilotRid Condition="'$(_CopilotRid)' == '' And $([MSBuild]::IsOSPlatform('OSX')) And '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'Arm64'">osx-arm64</_CopilotRid> |
| 9 | + <!-- Use explicit RuntimeIdentifier if it matches a supported portable RID --> |
| 10 | + <_CopilotRid Condition="'$(RuntimeIdentifier)' == 'win-x64'">win-x64</_CopilotRid> |
| 11 | + <_CopilotRid Condition="'$(RuntimeIdentifier)' == 'win-arm64'">win-arm64</_CopilotRid> |
| 12 | + <_CopilotRid Condition="'$(RuntimeIdentifier)' == 'linux-x64'">linux-x64</_CopilotRid> |
| 13 | + <_CopilotRid Condition="'$(RuntimeIdentifier)' == 'linux-arm64'">linux-arm64</_CopilotRid> |
| 14 | + <_CopilotRid Condition="'$(RuntimeIdentifier)' == 'osx-x64'">osx-x64</_CopilotRid> |
| 15 | + <_CopilotRid Condition="'$(RuntimeIdentifier)' == 'osx-arm64'">osx-arm64</_CopilotRid> |
| 16 | + <!-- Detect from build host only when no explicit RuntimeIdentifier is set --> |
| 17 | + <_CopilotRid Condition="'$(_CopilotRid)' == '' And '$(RuntimeIdentifier)' == '' And $([MSBuild]::IsOSPlatform('Windows')) And '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'X64'">win-x64</_CopilotRid> |
| 18 | + <_CopilotRid Condition="'$(_CopilotRid)' == '' And '$(RuntimeIdentifier)' == '' And $([MSBuild]::IsOSPlatform('Windows')) And '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'Arm64'">win-arm64</_CopilotRid> |
| 19 | + <_CopilotRid Condition="'$(_CopilotRid)' == '' And '$(RuntimeIdentifier)' == '' And $([MSBuild]::IsOSPlatform('Linux')) And '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'X64'">linux-x64</_CopilotRid> |
| 20 | + <_CopilotRid Condition="'$(_CopilotRid)' == '' And '$(RuntimeIdentifier)' == '' And $([MSBuild]::IsOSPlatform('Linux')) And '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'Arm64'">linux-arm64</_CopilotRid> |
| 21 | + <_CopilotRid Condition="'$(_CopilotRid)' == '' And '$(RuntimeIdentifier)' == '' And $([MSBuild]::IsOSPlatform('OSX')) And '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'X64'">osx-x64</_CopilotRid> |
| 22 | + <_CopilotRid Condition="'$(_CopilotRid)' == '' And '$(RuntimeIdentifier)' == '' And $([MSBuild]::IsOSPlatform('OSX')) And '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'Arm64'">osx-arm64</_CopilotRid> |
15 | 23 | </PropertyGroup> |
16 | 24 |
|
| 25 | + <!-- Fail early if an explicit RID was given but not recognized --> |
| 26 | + <Target Name="_ValidateCopilotRid" BeforeTargets="BeforeBuild" Condition="'$(RuntimeIdentifier)' != '' And '$(_CopilotRid)' == ''"> |
| 27 | + <Error Text="RuntimeIdentifier '$(RuntimeIdentifier)' is not a supported portable RID for the Copilot CLI. Supported RIDs: win-x64, win-arm64, linux-x64, linux-arm64, osx-x64, osx-arm64." /> |
| 28 | + </Target> |
| 29 | + |
17 | 30 | <!-- Map RID to platform name used in npm packages --> |
18 | 31 | <PropertyGroup> |
19 | 32 | <_CopilotPlatform Condition="'$(_CopilotRid)' == 'win-x64'">win32-x64</_CopilotPlatform> |
|
0 commit comments