In my NuGet package, I add a solution folder using the method shown here: https://stackoverflow.com/a/6478804/1628707
Here's my code to add the solution folder, in Init.ps.
$solutionFolder = $solution.AddSolutionFolder("build")
$folderItems = Get-Interface $solutionFolder.ProjectItems ([EnvDTE.ProjectItems])
$files = Get-ChildItem "$buildFolder"
foreach ($file in $files)
{
$folderItems.AddFromFile($file.FullName)
}
Now, in Uninstall.ps, I want to remove the solution folder named "build." I've tried the following.
//try to get the solution folder. This fails with 'doesn't contain a method named Item'
$proj = $solution.Projects.Item("build")
//So, I tried enumerating and finding the item by name. This works.
foreach ($proj in $solution.Projects)
{
if ($proj.Name -eq "build")
{
$buildFolder = $proj
}
}
//But then removing fails with 'doesn't contain a method named Remove'
$solution.Remove($buildFolder)
I'm stymied and will appreciate any suggestions.
Not sure why Item is being difficult but another way to do this would be:
$proj = $solution.Projects | Where {$_.ProjectName -eq "build"}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With