nuget-serverproget

Delete all but last 10 NuGet packages \ NuGet package retention feature request


We would like to start using ProGet for dependencies in CI builds & their dependencies, however this can cause a lot of NuGet packages to sit in the feed and the only option is to delete one at a time or the entire feed.

Is there an alternate way to delete all but the last 10 or better yet implement NuGet package retention policies on the feeds?

Many Thanks


Solution

  • This feature is definitely on our list to implement, though it has taken a back seat to Maven & Linux support for the time being. For now, you can probably whip up a quick PowerShell script though that does something like:

    get-childitem "C:\PackagePath\FeedName\PackageName" 
      | sort-object $.CreatedDate -descending | select-object -skip 10 | remove-item
    

    Of course this uses the modified date instead of the version number, the retention policy feature could use the package's version number to determine which packages to retain.

    Update - April 21, 2015:

    The retention policy feature will be included in the upcoming ProGet v3.6.