Changing name for Nuget Package

1.6k views Asked by At

I have a Nuget package. Example: 'Sample'. I have generated a .nupkg file using nuspec file. and then pushed 'Sample' nuget package to feed using Nuget push azure build task.

my nuspec file:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
  <metadata>
       <id>Sample</id>
      <version>1.0.0.0</version>
        <title>Sample</title>
    <authors>Name</authors>
    <copyright>Copyright © 2009-2019. All rights reserved.</copyright>   
    <tags>Sample</tags>  
    <description>This package is for testing.</description>
    <owners>Name</owners>  
  </metadata>
  <files>   
    <file src="./Sample.dll" target="lib\net46\Sample.dll"/>
  </files>
</package>

Now I want to change the name of my nuget package, For example: 'SamplePackageForTesting'.

Nuget pakage name is not updated eventhough I change the title, and then pushed.

But when I change the id and push, then it is updating as new package.

Can you provide any solution how to change the name of my nuget package 'Sample' to 'SamplePackageForTesting'.

2

There are 2 answers

0
mu88 On BEST ANSWER

A rename is not possible: from NuGet's perspective, Sample and SamplePackageForTesting are two different packages as they have different IDs.

If you're using nuget.org, a workaround would be to deprecate your package (see here).

And if the NuGet feed is under your control you could also delete the Sample package. But for this, you have to make sure that nobody ever consumed it because otherwise deterministic builds won't be possible when going back in Git history.

0
AaronLS On

When you choose the deprecation option, an option to enter an alternate package name will appear. The new renamed package must already be uploaded and processing completed to list it.

enter image description here

The landing page for your depracated nuget package will then show a link to the alternate: enter image description here