none
Delete multiple nuget packages using powershell RRS feed

  • Question

  • Hi,

    Using powershell I am trying to delete multiple nuget packages from our nuget repository. But confirmation is coming

    I tried suppressing it but it didn't worked.

    foreach ($package in $packages | select-object -first ($packages.count - $retentioncount))
    {
    &$nugetPath delete $nugetFolderPath\$packageName $package $key -source $nugetSource -Recurse -Force
    }


    :failing with Unknown option: '-Recurse'

    Also,

    foreach ($package in $packages | select-object -first ($packages.count - $retentioncount))
    {

    &$nugetPath delete $nugetFolderPath\$packageName $package $key -source $nugetSource -Recurse -Confirm:$Y

    }

    :still asking for confirmation

    Thursday, May 4, 2017 2:53 PM

Answers

  • Hi Cole,

    It worked with '-NonInteractive'

    &$nugetPath delete $packageName $package $key -source $nugetSource -Force -NonInteractive

    Thanks for your time.

    • Marked as answer by Irfspy Friday, May 5, 2017 12:17 PM
    Friday, May 5, 2017 9:21 AM

All replies

  • Hi Irfspy,

    Please try the following code. it works on my side.

     get-childitem "D:\Project\Msbuild\App1\packages" | remove-item -recurse

    Best regards,

    Cole Wu


    MSDN Community Support<br/> Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact <a href="mailto:MSDNFSF@microsoft.com">MSDNFSF@microsoft.com</a>.

    Friday, May 5, 2017 8:01 AM
    Moderator
  • Hi Cole,

    Normal directory I am able to delete using this but not able to delete the nuget package which is deployed in our nuget server.

    I tried:

    &$nugetPath delete $packageName $package $key -source $nugetSource -Force 

    But it is working from local using Powershell but while using same command over Jenkins it is asking yes or no as confirmation:

    Would you like to continue? (y/N) Object reference not set to an instance of an object.


    Friday, May 5, 2017 9:12 AM
  • Hi Cole,

    It worked with '-NonInteractive'

    &$nugetPath delete $packageName $package $key -source $nugetSource -Force -NonInteractive

    Thanks for your time.

    • Marked as answer by Irfspy Friday, May 5, 2017 12:17 PM
    Friday, May 5, 2017 9:21 AM
  • @Irfspy, Since you have resolve your question, you can mark it as answer, so it could help other community members who get the same issues. Thanks.

    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, May 5, 2017 9:56 AM