Skip to content

Commit 69eca40

Browse files
Always get from NPM
1 parent 35fd9d2 commit 69eca40

1 file changed

Lines changed: 13 additions & 19 deletions

File tree

dotnet/src/build/GitHub.Copilot.SDK.targets

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<_CopilotRid Condition="'$(_CopilotRid)' == '' And $([MSBuild]::IsOSPlatform('OSX')) And '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'Arm64'">osx-arm64</_CopilotRid>
1515
</PropertyGroup>
1616

17-
<!-- Map RID to platform name used in npm/GitHub releases -->
17+
<!-- Map RID to platform name used in npm packages -->
1818
<PropertyGroup>
1919
<_CopilotPlatform Condition="'$(_CopilotRid)' == 'win-x64'">win32-x64</_CopilotPlatform>
2020
<_CopilotPlatform Condition="'$(_CopilotRid)' == 'win-arm64'">win32-arm64</_CopilotPlatform>
@@ -24,7 +24,6 @@
2424
<_CopilotPlatform Condition="'$(_CopilotRid)' == 'osx-arm64'">darwin-arm64</_CopilotPlatform>
2525
<_CopilotBinary Condition="$(_CopilotRid.StartsWith('win-'))">copilot.exe</_CopilotBinary>
2626
<_CopilotBinary Condition="'$(_CopilotBinary)' == ''">copilot</_CopilotBinary>
27-
<_CopilotIsWindows Condition="$(_CopilotRid.StartsWith('win-'))">true</_CopilotIsWindows>
2827
</PropertyGroup>
2928

3029
<!-- Download and extract CLI binary -->
@@ -33,36 +32,31 @@
3332

3433
<!-- Compute paths using version (now available) -->
3534
<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>
4339
</PropertyGroup>
4440

4541
<!-- Download if not cached -->
4642
<MakeDir Directories="$(_CopilotCacheDir)" Condition="!Exists('$(_CopilotCliBinaryPath)')" />
4743
<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"
4945
Condition="!Exists('$(_CopilotCliBinaryPath)') And !Exists('$(_CopilotArchivePath)')" />
5046

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 -->
5448
<Exec Command="tar -xzf &quot;$(_CopilotArchivePath)&quot; --strip-components=1 -C &quot;$(_CopilotCacheDir)&quot;"
55-
Condition="'$(_CopilotIsWindows)' != 'true' And !Exists('$(_CopilotCliBinaryPath)')" />
49+
Condition="!Exists('$(_CopilotCliBinaryPath)')" />
5650

5751
<Error Condition="!Exists('$(_CopilotCliBinaryPath)')" Text="Failed to extract Copilot CLI binary to $(_CopilotCliBinaryPath)" />
5852
</Target>
5953

6054
<!-- Copy CLI binary to output runtimes folder and register for transitive copy -->
6155
<Target Name="_CopyCopilotCliToOutput" AfterTargets="Build" DependsOnTargets="_DownloadCopilotCli" Condition="'$(_CopilotPlatform)' != ''">
6256
<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>
6660
</PropertyGroup>
6761
<MakeDir Directories="$(_CopilotOutputDir)" />
6862
<Copy SourceFiles="$(_CopilotCliBinaryPath)" DestinationFolder="$(_CopilotOutputDir)" SkipUnchangedFiles="true" />
@@ -71,8 +65,8 @@
7165
<!-- Register CLI binary as content so it flows through project references -->
7266
<Target Name="_RegisterCopilotCliForCopy" BeforeTargets="GetCopyToOutputDirectoryItems" DependsOnTargets="_DownloadCopilotCli" Condition="'$(_CopilotPlatform)' != ''">
7367
<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>
7670
</PropertyGroup>
7771
<ItemGroup>
7872
<ContentWithTargetPath Include="$(_CopilotCliBinaryPath)"

0 commit comments

Comments
 (0)