Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions dotnet/src/build/GitHub.Copilot.SDK.targets
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@
<CopilotNpmRegistryUrl Condition="'$(CopilotNpmRegistryUrl)' == ''">https://registry.npmjs.org</CopilotNpmRegistryUrl>
</PropertyGroup>

<!-- Timeout in seconds for downloading the Copilot CLI tarball.
Override CopilotCliDownloadTimeout in your .csproj or Directory.Build.props if needed.
Default is 600 seconds (10 minutes) to handle slow or unreliable network conditions. -->
<PropertyGroup>
<CopilotCliDownloadTimeout Condition="'$(CopilotCliDownloadTimeout)' == ''">600</CopilotCliDownloadTimeout>
</PropertyGroup>
Comment on lines +54 to +56
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding input validation for the CopilotCliDownloadTimeout property to ensure it's a positive integer. Invalid values (negative numbers, zero, or non-numeric strings) could cause build failures with cryptic error messages. You could add a validation target or use MSBuild's Error condition, for example:

<Error Condition="$([System.Int32]::Parse('$(CopilotCliDownloadTimeout)')) &lt;= 0" Text="CopilotCliDownloadTimeout must be a positive integer (in seconds)." />

This would provide users with a clearer error message if they misconfigure the property.

Copilot uses AI. Check for mistakes.

<!-- Download and extract CLI binary -->
<Target Name="_DownloadCopilotCli" BeforeTargets="BeforeBuild" Condition="'$(_CopilotPlatform)' != ''">
<Error Condition="'$(CopilotCliVersion)' == ''" Text="CopilotCliVersion is not set. The GitHub.Copilot.SDK.props file may be missing from the NuGet package." />
Expand All @@ -68,6 +75,7 @@
<MakeDir Directories="$(_CopilotCacheDir)" Condition="!Exists('$(_CopilotCliBinaryPath)')" />
<Message Importance="high" Text="Downloading Copilot CLI $(CopilotCliVersion) for $(_CopilotPlatform)..." Condition="!Exists('$(_CopilotCliBinaryPath)')" />
<DownloadFile SourceUrl="$(_CopilotDownloadUrl)" DestinationFolder="$(_CopilotCacheDir)" DestinationFileName="copilot.tgz"
Timeout="$([System.Int32]::Parse('$(CopilotCliDownloadTimeout)'))"
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MSBuild DownloadFile task's Timeout parameter expects milliseconds, not seconds. The property is documented as "600 seconds (10 minutes)" but passing 600 directly to the Timeout parameter will be interpreted as 600 milliseconds (0.6 seconds), which will cause downloads to fail almost immediately.

The value should be multiplied by 1000 to convert from seconds to milliseconds. For example:
Timeout="$([System.Int32]::Parse('$(CopilotCliDownloadTimeout)') * 1000)"

This ensures that a value of 600 results in a 600,000 millisecond (600 second) timeout.

This issue also appears on line 51 of the same file.

Suggested change
Timeout="$([System.Int32]::Parse('$(CopilotCliDownloadTimeout)'))"
Timeout="$([System.Int32]::Parse('$(CopilotCliDownloadTimeout)') * 1000)"

Copilot uses AI. Check for mistakes.
Condition="!Exists('$(_CopilotCliBinaryPath)')" />

<!-- Extract using tar (use Windows system tar explicitly to avoid Git bash tar issues) -->
Expand Down
Loading