Skip to content

Support dotnet add, update, remove pkg

Alex Panov edited this page Apr 19, 2017 · 1 revision

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 ref command. 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|--prerelease We have decided that we will not need this switch because -

    1. Restore does not have a prerelease options.
    2. 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.

Contributing

What's Being Worked On?

Check out the proposals in the accepted & proposed folders on the repository, and active PRs for proposals being discussed today.

Common Problems

Clone this wiki locally