1

I am trying to remove and delete the files from a project during the install PowerShell of a NuGet package. I have the code below that removes it from the project, but I cannot figure out how to pipe that so I can also delete it from disk. How do I do this?

$project.ProjectItems.Item("Test123").Remove() | Select-Object | Get-ChildItem -Recurse | Remove-Item -force -recurse
3
  • What does the Remove method return? Commented Mar 15, 2013 at 12:52
  • Hmmm not sure how to debug PowerShell especially if NuGet is triggering it (I'm a newbie to ps) Commented Mar 15, 2013 at 12:54
  • 1
    Looks like it's this method, returns nothing. Commented Mar 15, 2013 at 13:07

1 Answer 1

4

Looks like instead of calling Remove you should call Delete.

From documentation for Remove

Removes the project item from the collection.

From documentation for Delete emphasis mine

Removes the item from its project and its storage.

Sign up to request clarification or add additional context in comments.

1 Comment

@TruMan1: MSDN is your friend, don't be shy about digging around the documentation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.