Support dotnet add, update, remove pkg
Pages 155
Home
Contributing
Specs
Incubation
Reviewing
- Centrally-managing-NuGet-package-versions
- Package Applicability
- dotnet list package --vulnerable
- Machine-readable output for dotnet list package
- Support Package Renames
- Advanced Search on NuGet.org
Reviewed
Implemented
- Enhanced package upload workflow
- Register package signing certificates
- Organizations on NuGet.org
- 2 Factor Auth for NuGet.org sign in
- Add nuget sources command to the dotnet CLI
- Author Package Signing
- Backporting PC to msbuild restore
- Deprecate packages
- Dotnet list package
- Enable repeatable package restore using lock file
- NuGet Client Package Debugging
- NuGet Package Debugging & Symbols Improvements
- NuGet Package Identity Verification
- NuGet Package Signing Client Policy
- NuGet Sign Command
- NuGet Verify Command
- Storing trusted repository
- Package Signatures Technical Details
- Package signing
- Packages.config SHA Validation
- Packaging Icon, License and Documentation within the nupkg
- Repository Signatures and Countersignatures Technical Specification
- Repository Signatures
- Show outdated packages
- Symbols Package Upload and Delete Workflow
Templates
Clone this wiki locally
Issue
https://github.com/NuGet/Home/issues/3751
Problem
Currently, there is no way of adding, update and removing package references in dotnet cli
Who is the customer?
Any one using dotnet cli.
Evidence
The request comes from dotnet cli team that has initiated the process of adding a dotnet add|remove|update|list <type> <id> command at https://github.com/dotnet/cli/issues/4521
Solution
We should add support for handling dotnet add|update|remove package <id> where the type of reference is package reference.
- The Flow would be
dotnet add|update|remove package <id>would invoke dotnet cli, which would pass the information to a NuGet.xplat api. - We will then use msbuild.construction api to perform the task.
Usage
dotnet add package <id> [--version|-v] [--framework|-f] [--no-restore|-n] [--source|-s] [--package-directory]
dotnet update package <id> [--version|-v] [--framework|-f] [--no-restore|-n]
dotnet remove package <id>
Change Requests
-
PreRelease Switch - We need a pre-release switch/flag from
dotnet refcommand. This would work the same way as the pre-release check box in the VS UI.
e.g. -dotnet add ref pkg Newtonsoft.Json -p|--prereleaseWe have decided that we will not need this switch because -- Restore does not have a prerelease options.
- User can just specify x.y.z-* for prerelease packages.
-
Update sub verb - From NuGet's perspective an update ref sub-command makes sense.
e.g. -dotnet update package Newtonsoft.Json [-v|--version] -
Empty Version String - The behavior when user does not specify an exact version should be consistent with other nuget operations.
e.g. -dotnet update ref pkg Newtonsoft.Json-> Should be same as ->dotnet ref update Newtonsoft.Json -v|--version '*'. But we write the resolved version in the csproj file. -
Multi-Targeting - We should have support for multi targeting.
| Sr. No. | Project TFM | Package TFM | Sample Reference |
| 1 | netcoreapp1.0 and net46 | netcoreapp1.0 and net46 |
<ItemGroup>
<PackageReference Include="NewtonSoft.Json">
<version>9.0.1</version>
</PackageReference>
</ItemGroup>
|
| 2 | netcoreapp1.0 and net46 | netcoreapp1.0 |
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp1.0' "> <PackageReference Include="NewtonSoft.Json"> <version>9.0.1</version> </PackageReference> </ItemGroup> |
| 3 | netcoreapp1.0 | netcoreapp1.0 and net46 |
<ItemGroup>
<PackageReference Include="NewtonSoft.Json">
<version>9.0.1</version>
</PackageReference>
</ItemGroup>
|
Open Questions
-
Which API? - Microsoft.Build.Construction
-
Kick off restore after add/update ref? - In case a package ref is added or updated, VS kicks off a restore. Current answer is No.
-
Include private/public Assets? - This is not done at any platform i.e. nuget.exe/VS etc. Current answer is No.