Skip to content

Fix Copilot CLI acquisition behind npm mirrors and cache it per machine - #114

Merged
MikeAlhayek merged 2 commits into
mainfrom
ma/fix-copilot-cli-download
Jul 27, 2026
Merged

Fix Copilot CLI acquisition behind npm mirrors and cache it per machine#114
MikeAlhayek merged 2 commits into
mainfrom
ma/fix-copilot-cli-download

Conversation

@MikeAlhayek

Copy link
Copy Markdown
Member

The GitHub.Copilot.SDK build targets download the Copilot CLI tarball from a hardcoded https://registry.npmjs.org, and MSBuild's DownloadFile task cannot read npm configuration. Machines and build agents behind a corporate proxy or an artifact mirror block that host, so consuming projects fail to build with a connectivity error even though npm itself is configured correctly.

The SDK also caches the CLI under the intermediate output path, which is per project and per configuration, so a solution with several referencing projects downloads the same ~100 MB tarball once per project, and again for every fresh clone, worktree or CI agent.

The buildTransitive bridge now resolves the effective npm registry from NPM_CONFIG_REGISTRY, falling back to npm config get registry, and redirects the SDK cache to a machine wide location under the NuGet global packages folder. Both behaviors are opt-out through CopilotResolveNpmRegistry and CopilotUseSharedCliCache, the cache location is configurable through CopilotCliCacheDir so a pre-seeded directory supports offline builds, and an explicitly set CopilotNpmRegistryUrl, CopilotCliBinaryPath or CopilotSkipCliDownload always takes precedence.

The bridge records whether the consumer supplied CopilotNpmRegistryUrl before importing the SDK targets, because the SDK assigns its own default during that import and the resolution would otherwise never run.

Also escapes the generated targets content before WriteLinesToFile so semicolons and percent signs in the template are written verbatim instead of being split into separate lines.

MikeAlhayek and others added 2 commits July 27, 2026 21:36
The GitHub.Copilot.SDK build targets download the Copilot CLI tarball from a
hardcoded https://registry.npmjs.org, and MSBuild's DownloadFile task cannot
read npm configuration. Machines and build agents behind a corporate proxy or
an artifact mirror block that host, so consuming projects fail to build with a
connectivity error even though npm itself is configured correctly.

The SDK also caches the CLI under the intermediate output path, which is per
project and per configuration, so a solution with several referencing projects
downloads the same ~100 MB tarball once per project, and again for every fresh
clone, worktree or CI agent.

The buildTransitive bridge now resolves the effective npm registry from
NPM_CONFIG_REGISTRY, falling back to `npm config get registry`, and redirects
the SDK cache to a machine wide location under the NuGet global packages
folder. Both behaviors are opt-out through CopilotResolveNpmRegistry and
CopilotUseSharedCliCache, the cache location is configurable through
CopilotCliCacheDir so a pre-seeded directory supports offline builds, and an
explicitly set CopilotNpmRegistryUrl, CopilotCliBinaryPath or
CopilotSkipCliDownload always takes precedence.

The bridge records whether the consumer supplied CopilotNpmRegistryUrl before
importing the SDK targets, because the SDK assigns its own default during that
import and the resolution would otherwise never run.

Also escapes the generated targets content before WriteLinesToFile so
semicolons and percent signs in the template are written verbatim instead of
being split into separate lines.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The properties documented alongside the shared cache and npm registry
resolution are override knobs, not setup steps. The wording and the
Directory.Build.props example made them look required.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@MikeAlhayek
MikeAlhayek merged commit 0cc5d1d into main Jul 27, 2026
11 checks passed
@MikeAlhayek
MikeAlhayek deleted the ma/fix-copilot-cli-download branch July 27, 2026 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant