Fix Copilot CLI acquisition behind npm mirrors and cache it per machine - #114
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.