Skip to content

[ISSUE]: System.Collections.Immutable is included in runtime packages due to its placement after PackageReference update #4593

@joao-genebra

Description

@joao-genebra

Prerequisites

  • I have written a descriptive issue title
  • I have searched issues to ensure it has not already been reported

GitVersion package

GitVersion.MsBuild

GitVersion version

6.2.0

Operating system

N/A

What are you seeing?

In GitVersion.MsBuild.csproj, the System.Collections.Immutable package reference is currently placed after the line:

<PackageReference Update="@(PackageReference)" PrivateAssets="All" />

This causes System.Collections.Immutable to be packaged into the runtime NuGet packages, which seems unintended for a build-time-only dependency.

Relevant snippet:
https://github.com/GitTools/GitVersion/blob/d095febb1ec8ccd7ce5e20ab767cb6c6e1ee4412/src/GitVersion.MsBuild/GitVersion.MsBuild.csproj#L16C5-L23C17

Since the Update is applied before System.Collections.Immutable is declared, the PrivateAssets="All" metadata does not apply to it, leading to it being included in the runtime assets.

What is expected?

System.Collections.Immutable should be marked as a build-time-only dependency using PrivateAssets="All", and therefore should not be included in the runtime dependencies of projects that consume GitVersion.MsBuild.

Steps to Reproduce

  1. Create a new .NET project.

  2. Add a reference to the GitVersion.MsBuild NuGet package.

  3. Publish the project and check the output directory to confirm that System.Collections.Immutable.dll is included in the runtime output.

RepositoryFixture Test

No response

Output log or link to your CI build (if appropriate).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions