'Can not delete a nuget package with the dotnet cli

I can not delete a nuget package with the dotnet cli.

Here is the command I am running:

dotnet nuget delete package AutoMapper.Extensions.Microsoft.DependencyInjection 7.0.0

Here is the error I am getting:

error: Source parameter was not specified.

enter image description here

Here is my .csproj file:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="7.0.0" />
    <PackageReference Include="Braintree" Version="4.17.0" />
    <PackageReference Include="BraintreeHttp-Dotnet" Version="0.3.0" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.4" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.3">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.3">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.5.1" />
    <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.3" />
    <PackageReference Include="PayPalCheckoutSdk" Version="1.0.3" />
    <PackageReference Include="PayPalHttp" Version="1.0.0" />
    <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.5.1" />
  </ItemGroup>

</Project>

What am I missing here?



Solution 1:[1]

As far as I can see, you are looking for dotnet remove package (docs) to remove package from CSPROJ, while dotnet nuget delete package (source) removes it from nuget server (that's why you need to specify source)

Solution 2:[2]

This should be the command

dotnet remove package YourPackageName

Note there should be no version in there. So the following will not work.

 dotnet remove package YourPackageName --version 1.0.0

If you include the version, then you will get the following error.

Specify only one package reference to remove.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Krzysiek Szymczak
Solution 2 VivekDev