Include Copilot CLI runtime assets in PackAsTool packages - #2557
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The Windows net472 test build cannot resolve ZipFile without System.IO.Compression.FileSystem.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Fixes PackAsTool publishing so RID-specific packages include usable Copilot CLI runtime assets.
Changes:
- Publishes runtime assets and compatibility markers.
- Restores Unix executable permissions.
- Adds cross-platform packaging, launch tests, and CI coverage.
File summaries
| File | Description |
|---|---|
dotnet/test/Unit/RuntimeWrapperTests.cs |
Tests CLI precedence and Unix executable restoration. |
dotnet/test/Unit/MSBuildTargetsTests.cs |
Tests RID-specific tool packaging. |
dotnet/test/GitHub.Copilot.SDK.Test.csproj |
Updates test-project compression references, but lacks the required System.IO.Compression.FileSystem reference for net472. |
dotnet/src/Client.cs |
Handles compatibility markers and Unix permissions. |
dotnet/src/build/GitHub.Copilot.SDK.targets |
Publishes RID-specific runtime assets. |
.github/workflows/dotnet-sdk-tests.yml |
Adds Unix .NET 6–8 compatibility coverage. |
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
e68a27a to
364a173
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The regression test must verify both required runtime assets.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Balanced
364a173 to
dc7e2a2
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The regression test must assert the platform-specific renamed FFI library entry.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Balanced
dc7e2a2 to
39d8fa7
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The regression test must use a consistent architecture source; marker-only coverage should also be added.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (1)
dotnet/test/Unit/MSBuildTargetsTests.cs:252
- Add a marker-only tool-package case. This test passes
CopilotCliBinaryPathbut also seeds the runtime pair, so.copilot-explicit-cliis swept up by_CopilotRuntimeRootAsset; removingCopyToPublishDirectoryfrom the marker's dedicated registration would still pass. With an explicit binary and no cached pair,CopilotClientrelies on that marker to launch the alias instead of requiringcopilot-runtimeplusruntime.node, so this publish path remains unprotected.
using var sandbox = MSBuildSandbox.Create(packAsTool: true);
var preinstalled = sandbox.WritePreinstalledBinary("fake-cli-contents");
sandbox.WriteRuntimeCacheAsset("prebuilds", GetReleasePlatform(), "runtime.node", "runtime");
sandbox.WriteRuntimeCacheAsset("prebuilds", GetReleasePlatform(), RuntimeWrapperName, "wrapper");
sandbox.WriteRuntimeCacheAsset("ripgrep", "bin", GetReleasePlatform(), "rg", "ripgrep");
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Balanced
39d8fa7 to
4eb99cb
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Add package coverage proving the explicit-CLI marker is included when no runtime wrapper pair is seeded.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Balanced
4eb99cb to
e82dcc2
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Published runtime assets removed from later CLI bundles can remain stale and be packed by pack --no-build; cleanup and regression coverage are needed.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Balanced
Tool packages are produced from the publish layout, but the SDK registered its Copilot CLI runtime assets only for build output. `dotnet pack --no-build` therefore produced a tool package with no `runtimes/<rid>/native` payload, and the installed tool failed with "Copilot runtime wrapper not found". Register the existing runtime asset items before publish item collection as well and give them `CopyToPublishDirectory`, so the assets already staged for build output also reach the publish layout the tool package is built from.
e82dcc2 to
88fe17b
Compare
There was a problem hiding this comment.
🟢 Approval recommended
The publish registration addresses the reported packaging failure and the regression tests cover each independently registered runtime payload.
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0 new
- Review effort level: Balanced
Fixes #2067
Problem
Tool packages are produced from the publish layout, but the SDK registered its Copilot CLI runtime assets only for build output. When a
PackAsToolproject was packed without rebuilding — the usual CI sequence, anddotnet pack --no-buildin general — the resulting package contained noruntimes/<rid>/nativepayload, and the installed tool failed:Change
Register the existing runtime asset items before publish item collection as well as build output, and give them
CopyToPublishDirectory, so assets already staged for build output also reach the publish layout the tool package is built from.The item set, RID selection, download and cache behavior, output paths, and runtime precedence are unchanged. This does not rename the explicit-CLI marker, change stale-file replacement, alter execute permissions, or add CI jobs.
Validation
MSBuildTargetsTests— 11 passing onnet8.0and onnet472;GitHub.Copilot.Test.Unit— 291 passingdotnet format --verify-no-changescopilot-runtime[.exe],runtime.node, the renamed FFI library (copilot_runtime.dll/libcopilot_runtime.*) thatRuntimeConnection.ForInProcess()resolves, and a ripgrep asset. Reverting the targets change fails it, and so does droppingCopyToPublishDirectoryfrom any single one of those registrations — each was confirmed by mutating that item alone.PackAsToolproject outside the repository, then installing the produced tool withdotnet tool install --tool-pathand running it with all CLI overrides removed:main: 0runtimes/*/nativeentries in the tool package; the installed tool crashed with the error above.copilot-runtime.exeandruntime.node; the installed tool started the real Copilot CLI from its own packaged assets and completed an RPC round trip.pack -r <rid>and multi-RIDRuntimeIdentifiersalready packaged the assets before this change, so the defect is specific to packing without rebuilding.