Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPM - Updating GlobalPackageReference adds PackageVersion and PackageReference references to .csproj #13337

Open
lauraneto opened this issue Mar 20, 2024 · 3 comments
Labels
Area:RestoreCPM Central package management Functionality:Restore Priority:2 Issues for the current backlog. Type:Bug

Comments

@lauraneto
Copy link

NuGet Product Used

Visual Studio Package Management UI

Product Version

VS 17.9.4

Worked before?

No response

Impact

It's more difficult to complete my work

Repro Steps & Context

Reproduction steps

  1. Add a GlobalPackageReference entry to the Directory.Packages.props file.
    Example:
<Project>
  ...
  <ItemGroup>
    <GlobalPackageReference Include="Roslynator.Analyzers" Version="4.11.0" />
  <ItemGroup>
</Project>
  1. Update the Roslynator.Analyzers package to 4.12.0 through VS.
  2. Verify that the following lines were unexpectedly added to the .csproj file
<Project>
  ...
  <ItemGroup>
    <PackageVersion Update="Roslynator.Analyzers" Version="4.12.0" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Update="Roslynator.Analyzers">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
    </PackageReference>
  </ItemGroup>
</Project>

Workaround

As a workaround, instead of using GlobalPackageReference it's possible to simply use a PackageReference, which works correctly with the Visual Studio Package Management UI.
The problem with this workaround is that when trying to add nuget packages via the CLI, an error will be shown due to this check: https://github.com/NuGet/NuGet.Client/blob/5789cc8f9cf67f421000af06040b0f73aa9ae2d9/src/NuGet.Core/NuGet.CommandLine.XPlat/Utility/MSBuildAPIUtility.cs#L187-L192

Verbose Logs

No response

@jeffkl jeffkl added Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Area:RestoreCPM Central package management Pipeline:Icebox and removed Triage:Untriaged labels Mar 20, 2024
@Bertk
Copy link

Bertk commented Aug 15, 2024

Please fix this bug and make the Global Package References feature usable.

I see this bug very often and the cleanup of unwanted modifications is time consuming because not everybody checks the results of a Visual Studio Manage Nuget Packages for Solution ... operation.

image

@madskristensen Please recognize this bug.

@madskristensen
Copy link

@JonDouglas

@hakenr
Copy link

hakenr commented Oct 19, 2024

This is a major pain, making the GlobalPackageReference feature unusable for teams updating package references with the Visual Studio NuGet Package Manager.
Even when using the central <PackageVersion /> for those GlobalReferences, the <PackageReference /> (without version) still gets added to the individual .csproj files.

@nkolev92 nkolev92 added Priority:2 Issues for the current backlog. and removed Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Triage:NeedsTriageDiscussion labels Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area:RestoreCPM Central package management Functionality:Restore Priority:2 Issues for the current backlog. Type:Bug
Projects
None yet
Development

No branches or pull requests

6 participants