Skip to content

[.NET] build/GitHub.Copilot.SDK.props missing from 1.0.0-beta.6 NuGet package (multi-targeting regression) #1375

@mk185147

Description

@mk185147

Summary

The build/GitHub.Copilot.SDK.props file is missing from the 1.0.0-beta.6 NuGet package. This file should contain <CopilotCliVersion>1.0.51</CopilotCliVersion> but is not present, causing the _DownloadCopilotCli target to fail with:

CopilotCliVersion is not set. The GitHub.Copilot.SDK.props file may be missing from the NuGet package.

The previous release (1.0.0-beta.4) correctly included this file with <CopilotCliVersion>1.0.46</CopilotCliVersion>.

Reproduction

<PackageReference Include="GitHub.Copilot.SDK" Version="1.0.0-beta.6" />

Build any executable project referencing the SDK without manually setting CopilotCliVersion or CopilotSkipCliDownload. The build errors with the message above.

Workaround: Set <CopilotCliVersion>1.0.51</CopilotCliVersion> in Directory.Build.props or the consuming project file.

Root cause analysis

The .props file is generated at pack time by _GenerateVersionProps (in GitHub.Copilot.SDK.csproj), which adds it dynamically to the package via:

<Target Name="_GenerateVersionProps" DependsOnTargets="_GetCopilotCliVersion" BeforeTargets="Pack">
    <WriteLinesToFile File="$(MSBuildThisFileDirectory)build\GitHub.Copilot.SDK.props" ... />
    <ItemGroup>
        <None Include="build\GitHub.Copilot.SDK.props" Pack="true" PackagePath="build\" />
    </ItemGroup>
</Target>

PR #1320 made the SDK multi-targeted (net8.0;net10.0;netstandard2.0). In multi-targeted builds, dotnet pack runs the outer build (where TargetFramework is empty). Items added dynamically inside BeforeTargets="Pack" targets are not reliably visible to the NuGet Pack target's item evaluation in multi-targeted projects — a known class of MSBuild/NuGet ordering issues (see NuGet/Home#3891).

The .targets file is included statically (always packaged correctly):

<ItemGroup>
    <None Include="build\GitHub.Copilot.SDK.targets" Pack="true" PackagePath="build\" CopyToOutputDirectory="Never" />
</ItemGroup>

The .props file uses the dynamic pattern (fragile in multi-targeted builds).

Suggested fix

Statically include the .props file with an existence condition, and ensure the generation target runs early enough:

<!-- Static inclusion — always picked up by Pack -->
<ItemGroup>
    <None Include="build\GitHub.Copilot.SDK.props" Pack="true" PackagePath="build\" 
          Condition="Exists('build\GitHub.Copilot.SDK.props')" />
</ItemGroup>

Combined with ensuring _GenerateVersionProps has BeforeTargets="GenerateNuspec" or is wired via PackDependsOn for reliable ordering in multi-targeted builds.

Alternatively, generate the file in a target that runs earlier (e.g., BeforeTargets="Build" or a pre-pack script in CI) so it exists on disk before Pack evaluates static items.

Verification

# Confirm .props is missing from beta.6 package
$pkg = "$env:USERPROFILE\.nuget\packages\github.copilot.sdk\1.0.0-beta.6"
Test-Path "$pkg\build\GitHub.Copilot.SDK.props"  # False
Test-Path "$pkg\build\GitHub.Copilot.SDK.targets" # True

# Compare with beta.4
$pkg4 = "$env:USERPROFILE\.nuget\packages\github.copilot.sdk\1.0.0-beta.4"
Test-Path "$pkg4\build\GitHub.Copilot.SDK.props"  # True
Get-Content "$pkg4\build\GitHub.Copilot.SDK.props"
# <Project><PropertyGroup><CopilotCliVersion>1.0.46</CopilotCliVersion></PropertyGroup></Project>

Impact

Any consumer that relied on the automatic CLI download (the default behavior) will get a build error on upgrade to beta.6. The workaround is to set CopilotCliVersion manually or use CopilotSkipCliDownload=true.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions