|
14 | 14 | <_CopilotRid Condition="'$(_CopilotRid)' == '' And $([MSBuild]::IsOSPlatform('OSX')) And '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'Arm64'">osx-arm64</_CopilotRid> |
15 | 15 | </PropertyGroup> |
16 | 16 |
|
17 | | - <!-- Map RID to platform name used in npm/GitHub releases --> |
| 17 | + <!-- Map RID to platform name used in npm packages --> |
18 | 18 | <PropertyGroup> |
19 | 19 | <_CopilotPlatform Condition="'$(_CopilotRid)' == 'win-x64'">win32-x64</_CopilotPlatform> |
20 | 20 | <_CopilotPlatform Condition="'$(_CopilotRid)' == 'win-arm64'">win32-arm64</_CopilotPlatform> |
|
24 | 24 | <_CopilotPlatform Condition="'$(_CopilotRid)' == 'osx-arm64'">darwin-arm64</_CopilotPlatform> |
25 | 25 | <_CopilotBinary Condition="$(_CopilotRid.StartsWith('win-'))">copilot.exe</_CopilotBinary> |
26 | 26 | <_CopilotBinary Condition="'$(_CopilotBinary)' == ''">copilot</_CopilotBinary> |
27 | | - <_CopilotIsWindows Condition="$(_CopilotRid.StartsWith('win-'))">true</_CopilotIsWindows> |
28 | 27 | </PropertyGroup> |
29 | 28 |
|
30 | 29 | <!-- Download and extract CLI binary --> |
|
33 | 32 |
|
34 | 33 | <!-- Compute paths using version (now available) --> |
35 | 34 | <PropertyGroup> |
36 | | - <_CopilotCacheDir>$(IntermediateOutputPath)copilot-cli\$(CopilotCliVersion)\$(_CopilotPlatform)\</_CopilotCacheDir> |
37 | | - <_CopilotCliBinaryPath>$(_CopilotCacheDir)$(_CopilotBinary)</_CopilotCliBinaryPath> |
38 | | - <_CopilotArchiveExt Condition="'$(_CopilotIsWindows)' == 'true'">.zip</_CopilotArchiveExt> |
39 | | - <_CopilotArchiveExt Condition="'$(_CopilotIsWindows)' != 'true'">.tgz</_CopilotArchiveExt> |
40 | | - <_CopilotArchivePath>$(_CopilotCacheDir)copilot$(_CopilotArchiveExt)</_CopilotArchivePath> |
41 | | - <_CopilotDownloadUrl Condition="'$(_CopilotIsWindows)' == 'true'">https://github.com/github/copilot-cli/releases/download/v$(CopilotCliVersion)/copilot-$(_CopilotPlatform).zip</_CopilotDownloadUrl> |
42 | | - <_CopilotDownloadUrl Condition="'$(_CopilotIsWindows)' != 'true'">https://registry.npmjs.org/@github/copilot-$(_CopilotPlatform)/-/copilot-$(_CopilotPlatform)-$(CopilotCliVersion).tgz</_CopilotDownloadUrl> |
| 35 | + <_CopilotCacheDir>$(IntermediateOutputPath)copilot-cli\$(CopilotCliVersion)\$(_CopilotPlatform)</_CopilotCacheDir> |
| 36 | + <_CopilotCliBinaryPath>$(_CopilotCacheDir)\$(_CopilotBinary)</_CopilotCliBinaryPath> |
| 37 | + <_CopilotArchivePath>$(_CopilotCacheDir)\copilot.tgz</_CopilotArchivePath> |
| 38 | + <_CopilotDownloadUrl>https://registry.npmjs.org/@github/copilot-$(_CopilotPlatform)/-/copilot-$(_CopilotPlatform)-$(CopilotCliVersion).tgz</_CopilotDownloadUrl> |
43 | 39 | </PropertyGroup> |
44 | 40 |
|
45 | 41 | <!-- Download if not cached --> |
46 | 42 | <MakeDir Directories="$(_CopilotCacheDir)" Condition="!Exists('$(_CopilotCliBinaryPath)')" /> |
47 | 43 | <Message Importance="high" Text="Downloading Copilot CLI $(CopilotCliVersion) for $(_CopilotPlatform)..." Condition="!Exists('$(_CopilotCliBinaryPath)')" /> |
48 | | - <DownloadFile SourceUrl="$(_CopilotDownloadUrl)" DestinationFolder="$(_CopilotCacheDir)" DestinationFileName="copilot$(_CopilotArchiveExt)" |
| 44 | + <DownloadFile SourceUrl="$(_CopilotDownloadUrl)" DestinationFolder="$(_CopilotCacheDir)" DestinationFileName="copilot.tgz" |
49 | 45 | Condition="!Exists('$(_CopilotCliBinaryPath)') And !Exists('$(_CopilotArchivePath)')" /> |
50 | 46 |
|
51 | | - <!-- Extract: Windows uses Unzip, others use tar --> |
52 | | - <Unzip SourceFiles="$(_CopilotArchivePath)" DestinationFolder="$(_CopilotCacheDir)" |
53 | | - Condition="'$(_CopilotIsWindows)' == 'true' And !Exists('$(_CopilotCliBinaryPath)')" /> |
| 47 | + <!-- Extract using tar --> |
54 | 48 | <Exec Command="tar -xzf "$(_CopilotArchivePath)" --strip-components=1 -C "$(_CopilotCacheDir)"" |
55 | | - Condition="'$(_CopilotIsWindows)' != 'true' And !Exists('$(_CopilotCliBinaryPath)')" /> |
| 49 | + Condition="!Exists('$(_CopilotCliBinaryPath)')" /> |
56 | 50 |
|
57 | 51 | <Error Condition="!Exists('$(_CopilotCliBinaryPath)')" Text="Failed to extract Copilot CLI binary to $(_CopilotCliBinaryPath)" /> |
58 | 52 | </Target> |
59 | 53 |
|
60 | 54 | <!-- Copy CLI binary to output runtimes folder and register for transitive copy --> |
61 | 55 | <Target Name="_CopyCopilotCliToOutput" AfterTargets="Build" DependsOnTargets="_DownloadCopilotCli" Condition="'$(_CopilotPlatform)' != ''"> |
62 | 56 | <PropertyGroup> |
63 | | - <_CopilotCacheDir>$(IntermediateOutputPath)copilot-cli\$(CopilotCliVersion)\$(_CopilotPlatform)\</_CopilotCacheDir> |
64 | | - <_CopilotCliBinaryPath>$(_CopilotCacheDir)$(_CopilotBinary)</_CopilotCliBinaryPath> |
65 | | - <_CopilotOutputDir>$(OutDir)runtimes\$(_CopilotRid)\native\</_CopilotOutputDir> |
| 57 | + <_CopilotCacheDir>$(IntermediateOutputPath)copilot-cli\$(CopilotCliVersion)\$(_CopilotPlatform)</_CopilotCacheDir> |
| 58 | + <_CopilotCliBinaryPath>$(_CopilotCacheDir)\$(_CopilotBinary)</_CopilotCliBinaryPath> |
| 59 | + <_CopilotOutputDir>$(OutDir)runtimes\$(_CopilotRid)\native</_CopilotOutputDir> |
66 | 60 | </PropertyGroup> |
67 | 61 | <MakeDir Directories="$(_CopilotOutputDir)" /> |
68 | 62 | <Copy SourceFiles="$(_CopilotCliBinaryPath)" DestinationFolder="$(_CopilotOutputDir)" SkipUnchangedFiles="true" /> |
|
71 | 65 | <!-- Register CLI binary as content so it flows through project references --> |
72 | 66 | <Target Name="_RegisterCopilotCliForCopy" BeforeTargets="GetCopyToOutputDirectoryItems" DependsOnTargets="_DownloadCopilotCli" Condition="'$(_CopilotPlatform)' != ''"> |
73 | 67 | <PropertyGroup> |
74 | | - <_CopilotCacheDir>$(IntermediateOutputPath)copilot-cli\$(CopilotCliVersion)\$(_CopilotPlatform)\</_CopilotCacheDir> |
75 | | - <_CopilotCliBinaryPath>$(_CopilotCacheDir)$(_CopilotBinary)</_CopilotCliBinaryPath> |
| 68 | + <_CopilotCacheDir>$(IntermediateOutputPath)copilot-cli\$(CopilotCliVersion)\$(_CopilotPlatform)</_CopilotCacheDir> |
| 69 | + <_CopilotCliBinaryPath>$(_CopilotCacheDir)\$(_CopilotBinary)</_CopilotCliBinaryPath> |
76 | 70 | </PropertyGroup> |
77 | 71 | <ItemGroup> |
78 | 72 | <ContentWithTargetPath Include="$(_CopilotCliBinaryPath)" |
|
0 commit comments