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

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

Closed
2 tasks done
kartheekp-ms opened this issue May 10, 2022 · 8 comments
Assignees

Comments

@kartheekp-ms
Copy link
Contributor

kartheekp-ms commented May 10, 2022

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

@kartheekp-ms kartheekp-ms 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 May 10, 2022
@zivkan zivkan added Priority:2 Issues for the current backlog. and removed Triage:NeedsTriageDiscussion labels May 12, 2022
@pragnya17
Copy link
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.

@darthkurak
Copy link

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

@kartheekp-ms
Copy link
Contributor Author

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

cc @martinrrm

@constantinmuraru
Copy link

constantinmuraru commented Jan 23, 2023

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

@kartheekp-ms
Copy link
Contributor Author

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.

@kartheekp-ms
Copy link
Contributor Author

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

@BenjaminBatman
Copy link

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

@martinrrm
Copy link
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
Projects
None yet
Development

No branches or pull requests

8 participants