Skip to content

Commit 96c8e8d

Browse files
Fix .NET SDK package; ensure no auto update (#392)
* Fix .NET SDK package missing props file The _GenerateVersionProps target was running BeforeTargets=BeforeBuild, but dotnet pack evaluates ItemGroup wildcards before targets run. This meant the generated .props file wasn't being included in the package. Fixed by: 1. Adding Pack to BeforeTargets so the target runs before packing 2. Explicitly adding the props file to pack content inside the target 3. Changing the static ItemGroup to only include the .targets file * Pass --no-auto-update to CLI across all SDKs Prevents the CLI from auto-updating itself, ensuring the version bundled with the SDK is the version that runs.
1 parent fc80c4e commit 96c8e8d

File tree

5 files changed

+11
-6
lines changed

5 files changed

+11
-6
lines changed

dotnet/src/Client.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ private async Task VerifyProtocolVersionAsync(Connection connection, Cancellatio
883883
args.AddRange(options.CliArgs);
884884
}
885885

886-
args.AddRange(["--headless", "--log-level", options.LogLevel]);
886+
args.AddRange(["--headless", "--no-auto-update", "--log-level", options.LogLevel]);
887887

888888
if (options.UseStdio)
889889
{

dotnet/src/GitHub.Copilot.SDK.csproj

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
</ItemGroup>
3030

3131
<!-- Generate version props file at build time (gitignored) -->
32-
<Target Name="_GenerateVersionProps" BeforeTargets="BeforeBuild">
32+
<Target Name="_GenerateVersionProps" BeforeTargets="BeforeBuild;Pack">
3333
<Exec Command="node -e &quot;console.log(require('./nodejs/package-lock.json').packages['node_modules/@github/copilot'].version)&quot;" WorkingDirectory="$(MSBuildThisFileDirectory)../.." ConsoleToMSBuild="true" StandardOutputImportance="low">
3434
<Output TaskParameter="ConsoleOutput" PropertyName="CopilotCliVersion" />
3535
</Exec>
@@ -44,12 +44,16 @@
4444
</_VersionPropsContent>
4545
</PropertyGroup>
4646
<WriteLinesToFile File="$(MSBuildThisFileDirectory)build\GitHub.Copilot.SDK.props" Lines="$(_VersionPropsContent)" Overwrite="true" WriteOnlyWhenDifferent="true" />
47+
<!-- Explicitly add props file to package content after generation -->
48+
<ItemGroup>
49+
<None Include="build\GitHub.Copilot.SDK.props" Pack="true" PackagePath="build\" />
50+
</ItemGroup>
4751
</Target>
4852

49-
<!-- Include .targets and .props files in package -->
53+
<!-- Include .targets file in package (props is added dynamically by _GenerateVersionProps) -->
5054
<!-- Also import the .targets for local dev (same logic consumers get) -->
5155
<ItemGroup>
52-
<None Include="build\GitHub.Copilot.SDK.*" Pack="true" PackagePath="build\" CopyToOutputDirectory="Never" />
56+
<None Include="build\GitHub.Copilot.SDK.targets" Pack="true" PackagePath="build\" CopyToOutputDirectory="Never" />
5357
</ItemGroup>
5458
<Import Project="build\GitHub.Copilot.SDK.targets" />
5559

go/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1313,7 +1313,7 @@ func (c *Client) verifyProtocolVersion(ctx context.Context) error {
13131313
// This spawns the CLI server as a subprocess using the configured transport
13141314
// mode (stdio or TCP).
13151315
func (c *Client) startCLIServer(ctx context.Context) error {
1316-
args := []string{"--headless", "--log-level", c.options.LogLevel}
1316+
args := []string{"--headless", "--no-auto-update", "--log-level", c.options.LogLevel}
13171317

13181318
// Choose transport mode
13191319
if c.useStdio {

nodejs/src/client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,7 @@ export class CopilotClient {
986986
const args = [
987987
...this.options.cliArgs,
988988
"--headless",
989+
"--no-auto-update",
989990
"--log-level",
990991
this.options.logLevel,
991992
];

python/copilot/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,7 @@ async def _start_cli_server(self) -> None:
11161116
if not os.path.exists(cli_path):
11171117
raise RuntimeError(f"Copilot CLI not found at {cli_path}")
11181118

1119-
args = ["--headless", "--log-level", self.options["log_level"]]
1119+
args = ["--headless", "--no-auto-update", "--log-level", self.options["log_level"]]
11201120

11211121
# Add auth-related flags
11221122
if self.options.get("github_token"):

0 commit comments

Comments
 (0)