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 · 0 comments
Labels
Area:RestoreCPM Central package management Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area:RestoreCPM Central package management Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Type:Bug
Projects
None yet
Development

No branches or pull requests

2 participants