Skip to content

[Feature]: dotnet.exe add package support for projects onboarded onto central package management #11807

Closed

Description

@kartheekp-ms

NuGet Product(s) Involved

dotnet.exe

The Elevator Pitch

The dotnet add package command provides a convenient option to add or update a package reference in a project file. If the repo has been onboarded onto Central Package Management feature then the said command should add package reference to project (no version) and add a package version to the props file. Few scenarios to consider during implementation.

  • If the version already exists in the. props file then the command should update it.
  • If no version is specified for add package command, then add latest version to CPM props file.
  • In case of update the tooling changes the version number in .props file but no edits should be made to the project file.

Additional Context and Details

No response

Epic details

Activity

  1. changed the title [-][Feature]: dotnet.exe add package support for projects onboarded onto cental package management[/-] [+][Feature]: dotnet.exe add package support for projects onboarded onto central package management[/+] on May 10, 2022
  2. pragnya17 commented on May 23, 2022

    @pragnya17
    Contributor

    When using the CLI command dotnet add package on a project that is already onboarded to Central Package Management the following error is thrown: error: NU1008: Projects that use central package version management should not define the version on the PackageReference items but on the PackageVersion items: [PackageName].

    The aim of this project will be to resolve this by enabling the dotnet CLI command to be used, regardless of whether the project has been onboarded to CPM or not.

  3. darthkurak commented on Jul 20, 2022

    @darthkurak

    When we can expect a release of this functionality? :)

  4. kartheekp-ms commented on Aug 27, 2022

    @kartheekp-ms
    ContributorAuthor

    When we can expect a release of this functionality? :)

    cc @martinrrm

  5. constantinmuraru commented on Jan 23, 2023

    @constantinmuraru

    Hey @martinrrm @kartheekp-ms - is this working? I see a few PRs merged, but can't seem to make it work with dotnet 7.0.102:

    https://stackoverflow.com/questions/75213427/how-to-make-dotnet-add-work-with-central-package-management

    When I run dotnet add, a PackageReference is added in the .csproj file, which contains the version.
    Example:

    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.2" />

    This upsets CPM on dotnet restore:

    error NU1008: Projects that use central package version management should not define the version on the PackageReference items but on the PackageVersion items

  6. kartheekp-ms commented on Jan 24, 2023

    @kartheekp-ms
    ContributorAuthor

    PR NuGet/NuGet.Client#4987 is merged into .NET SDK 7.0.2xx. You can download the daily .NET SDK build from https://github.com/dotnet/installer/blob/main/README.md#table until .NET SDK 7.0.2xx is released publicly.

  7. kartheekp-ms commented on Jul 17, 2023

    @kartheekp-ms
    ContributorAuthor

    All the issues in this epic have been addressed. Hence closing this issue.

  8. BenjaminBatman commented on Jul 19, 2023

    @BenjaminBatman

    Hey @martinrrm @kartheekp-ms - I am trying to update an existing package in the Directory.Packages.props file to the newest version. However when running dotnet add [PROJECT] package [PACKAGE], the package never updates. If I remove the package from the .props file, it adds the latest version fine and if I add -v [LATEST] to command it will update it as well. However I won't easily know what the latest version is to add to the command. Is dotnet add [PROJECT] package [PACKAGE] the correct format that I should be using to update an existing package to the latest version in the .props file?

    I have the following installed
    .NET SDK 7.0.3xx
    Nuget 6.6.1.2

  9. martinrrm commented on Jul 20, 2023

    @martinrrm
    Contributor

    @BenjaminBatman Can you open a bug issue for this so we can track upvotes and move the conversation there? I just tested this, and the behavior is not the expected one, I'll investigate more about.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions