How do you delete Solution Folder and contents within a VS extension?

1

I'm writing a VS Extension for VS 2017, and need to remove a Solution Folder and its contents from the solution. I have been unable to find much documentation aside from using ProjectItem.Remove to remove items from a project and Project.Delete to remove a project from the solution. However, calling each of these methods results in the following exception:

The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

What is the proper way to delete Solution Folders in an extension?

visual-studio
visual-studio-extensions
envdte
asked on Stack Overflow Jan 23, 2019 by Glen Hughes • edited Jan 23, 2019 by Mo Reza Farahani

1 Answer

0

A Solution Folder is a project in a given solution like any other project.

To remove a project from a solution, you cannot call proj.Delete() which is not implemented as per official documentation:

Removes the project from the current solution.

Note that this method is not currently implemented.

Instead, you must must use dte.Solution.Remove(proj); and that should work for solution folders as well.

answered on Stack Overflow Jan 31, 2019 by Simon Mourier

User contributions licensed under CC BY-SA 3.0