Skip to content

PackAsTool: Copilot CLI binary not included in NuGet tool package (cross-platform) #2067

Description

@Marcus-Kanon

Description

When packaging a .NET application as a dotnet tool (PackAsTool=true) that depends on GitHub.Copilot.SDK, the native Copilot CLI binary is not included in the .nupkg tool layout. At runtime, the tool fails with:

Copilot runtime not found at '...tools/net10.0/win-x64/runtimes/win-x64/native/copilot.exe'.
Ensure the SDK NuGet package was restored correctly or provide an explicit RuntimeConnection.ForStdio(path: ...) / RuntimeConnection.ForTcp(path: ...).

Root Cause

The SDK's build targets use ContentWithTargetPath with CopyToOutputDirectory to copy the CLI binary to bin/runtimes/{rid}/native/. However, PackAsTool does not include ContentWithTargetPath items in the tool package layout. The binary ends up in the build output but not in the .nupkg.

Additionally, when building on a Linux CI agent, the SDK downloads only the Linux binary. Even with RuntimeIdentifiers=win-x64;linux-x64, the per-RID builds download the correct platform binary, but it still doesn't make it into the tool package.

Steps to Reproduce

  1. Create a project with PackAsTool=true and GitHub.Copilot.SDK reference
  2. Run dotnet pack on a Linux agent
  3. Install the tool on Windows via dotnet tool install or dotnet dpx
  4. Run the tool -> crash with "Copilot runtime not found"

Expected Behavior

The Copilot CLI binaries for all target RIDs should be included in the NuGet tool package, similar to how packages like libgit2sharp and SkiaSharp ship native binaries under runtimes/{rid}/native/ in the package itself.

Suggested Fix

Ship the Copilot CLI binaries as proper runtimes/{rid}/native/ assets in the GitHub.Copilot.SDK NuGet package (all supported platforms), instead of downloading them at build time. This would make PackAsTool, PublishSingleFile, and cross-platform CI packaging all work correctly.

Environment

  • GitHub.Copilot.SDK: 1.0.8-preview.0
  • .NET SDK: 10.0.302
  • OS: Linux (CI build agent) / Windows (runtime)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions