|
28 | 28 |
|
29 | 29 | <!-- Download and extract CLI binary --> |
30 | 30 | <Target Name="_DownloadCopilotCli" BeforeTargets="BeforeBuild" Condition="'$(_CopilotPlatform)' != ''"> |
31 | | - <Error Condition="'$(CopilotCliVersion)' == ''" Text="CopilotCliVersion is not set. The GitHub.Copilot.SDK.Version.props file may be missing from the NuGet package." /> |
| 31 | + <Error Condition="'$(CopilotCliVersion)' == ''" Text="CopilotCliVersion is not set. The GitHub.Copilot.SDK.props file may be missing from the NuGet package." /> |
32 | 32 |
|
33 | 33 | <!-- Compute paths using version (now available) --> |
34 | 34 | <PropertyGroup> |
|
38 | 38 | <_CopilotDownloadUrl>https://registry.npmjs.org/@github/copilot-$(_CopilotPlatform)/-/copilot-$(_CopilotPlatform)-$(CopilotCliVersion).tgz</_CopilotDownloadUrl> |
39 | 39 | </PropertyGroup> |
40 | 40 |
|
| 41 | + <!-- Delete archive if binary missing (handles partial/corrupted downloads) --> |
| 42 | + <Delete Files="$(_CopilotArchivePath)" Condition="!Exists('$(_CopilotCliBinaryPath)') And Exists('$(_CopilotArchivePath)')" /> |
| 43 | + |
41 | 44 | <!-- Download if not cached --> |
42 | 45 | <MakeDir Directories="$(_CopilotCacheDir)" Condition="!Exists('$(_CopilotCliBinaryPath)')" /> |
43 | 46 | <Message Importance="high" Text="Downloading Copilot CLI $(CopilotCliVersion) for $(_CopilotPlatform)..." Condition="!Exists('$(_CopilotCliBinaryPath)')" /> |
44 | 47 | <DownloadFile SourceUrl="$(_CopilotDownloadUrl)" DestinationFolder="$(_CopilotCacheDir)" DestinationFileName="copilot.tgz" |
45 | | - Condition="!Exists('$(_CopilotCliBinaryPath)') And !Exists('$(_CopilotArchivePath)')" /> |
| 48 | + Condition="!Exists('$(_CopilotCliBinaryPath)')" /> |
46 | 49 |
|
47 | | - <!-- Extract using tar --> |
48 | | - <Exec Command="tar -xzf "$(_CopilotArchivePath)" --strip-components=1 -C "$(_CopilotCacheDir)"" |
| 50 | + <!-- Extract using tar (use Windows system tar explicitly to avoid Git bash tar issues) --> |
| 51 | + <PropertyGroup> |
| 52 | + <_TarCommand Condition="$([MSBuild]::IsOSPlatform('Windows'))">$(SystemRoot)\System32\tar.exe</_TarCommand> |
| 53 | + <_TarCommand Condition="'$(_TarCommand)' == ''">tar</_TarCommand> |
| 54 | + </PropertyGroup> |
| 55 | + <Exec Command=""$(_TarCommand)" -xzf "$(_CopilotArchivePath)" --strip-components=1 -C "$(_CopilotCacheDir)"" |
49 | 56 | Condition="!Exists('$(_CopilotCliBinaryPath)')" /> |
50 | 57 |
|
51 | 58 | <Error Condition="!Exists('$(_CopilotCliBinaryPath)')" Text="Failed to extract Copilot CLI binary to $(_CopilotCliBinaryPath)" /> |
|
0 commit comments