Skip to content

Commit 52fe739

Browse files
Add CopilotSkipCliDownload option to .NET SDK
Add MSBuild property CopilotSkipCliDownload that when set to true skips automatic download and bundling of the Copilot CLI binary. This is useful for users who install the CLI separately (e.g., via npm or a package manager) and want to avoid the build-time download. When skipped, users must ensure COPILOT_CLI_PATH or the CliPath option points to a valid CLI installation at runtime. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ed51ab8 commit 52fe739

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,21 @@
5555
<CopilotCliDownloadTimeout Condition="'$(CopilotCliDownloadTimeout)' == ''">600</CopilotCliDownloadTimeout>
5656
</PropertyGroup>
5757

58+
<!-- Skip automatic download and bundling of the Copilot CLI binary.
59+
Set CopilotSkipCliDownload to true in your .csproj or Directory.Build.props if you install
60+
the Copilot CLI separately (e.g., via npm or a package manager) and don't want the SDK
61+
to download and bundle it.
62+
63+
When skipped, you must provide a valid CLI path at runtime via the CliPath option in
64+
CopilotClientOptions. If CliPath is not set and the bundled CLI is not found, the SDK
65+
will throw an InvalidOperationException when starting the client.
66+
67+
<PropertyGroup>
68+
<CopilotSkipCliDownload>true</CopilotSkipCliDownload>
69+
</PropertyGroup> -->
70+
5871
<!-- Download and extract CLI binary -->
59-
<Target Name="_DownloadCopilotCli" BeforeTargets="BeforeBuild" Condition="'$(_CopilotPlatform)' != ''">
72+
<Target Name="_DownloadCopilotCli" BeforeTargets="BeforeBuild" Condition="'$(CopilotSkipCliDownload)' != 'true' And '$(_CopilotPlatform)' != ''">
6073
<Error Condition="'$(CopilotCliVersion)' == ''" Text="CopilotCliVersion is not set. The GitHub.Copilot.SDK.props file may be missing from the NuGet package." />
6174

6275
<!-- Compute paths using version (now available) -->
@@ -90,7 +103,7 @@
90103
</Target>
91104

92105
<!-- Copy CLI binary to output runtimes folder and register for transitive copy -->
93-
<Target Name="_CopyCopilotCliToOutput" AfterTargets="Build" DependsOnTargets="_DownloadCopilotCli" Condition="'$(_CopilotPlatform)' != ''">
106+
<Target Name="_CopyCopilotCliToOutput" AfterTargets="Build" DependsOnTargets="_DownloadCopilotCli" Condition="'$(CopilotSkipCliDownload)' != 'true' And '$(_CopilotPlatform)' != ''">
94107
<PropertyGroup>
95108
<_CopilotCacheDir>$(IntermediateOutputPath)copilot-cli\$(CopilotCliVersion)\$(_CopilotPlatform)</_CopilotCacheDir>
96109
<_CopilotCliBinaryPath>$(_CopilotCacheDir)\$(_CopilotBinary)</_CopilotCliBinaryPath>
@@ -101,7 +114,7 @@
101114
</Target>
102115

103116
<!-- Register CLI binary as content so it flows through project references -->
104-
<Target Name="_RegisterCopilotCliForCopy" BeforeTargets="GetCopyToOutputDirectoryItems" DependsOnTargets="_DownloadCopilotCli" Condition="'$(_CopilotPlatform)' != ''">
117+
<Target Name="_RegisterCopilotCliForCopy" BeforeTargets="GetCopyToOutputDirectoryItems" DependsOnTargets="_DownloadCopilotCli" Condition="'$(CopilotSkipCliDownload)' != 'true' And '$(_CopilotPlatform)' != ''">
105118
<PropertyGroup>
106119
<_CopilotCacheDir>$(IntermediateOutputPath)copilot-cli\$(CopilotCliVersion)\$(_CopilotPlatform)</_CopilotCacheDir>
107120
<_CopilotCliBinaryPath>$(_CopilotCacheDir)\$(_CopilotBinary)</_CopilotCliBinaryPath>

0 commit comments

Comments
 (0)