Powershell 使用NuGet uninstall.ps删除解决方案文件夹

Powershell 使用NuGet uninstall.ps删除解决方案文件夹,powershell,nuget,Powershell,Nuget,在我的NuGet软件包中,我使用如下所示的方法添加了一个解决方案文件夹: 下面是我在Init.ps中添加解决方案文件夹的代码 $solutionFolder = $solution.AddSolutionFolder("build") $folderItems = Get-Interface $solutionFolder.ProjectItems ([EnvDTE.ProjectItems]) $files = Get-ChildItem "$buildFolder" foreach ($f

在我的NuGet软件包中,我使用如下所示的方法添加了一个解决方案文件夹:

下面是我在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)
}
现在,在Uninstall.ps中,我想删除名为“build”的解决方案文件夹

//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)

我很困惑,希望您能给我一些建议。

我不知道为什么这个项目很难,但另一种方法是:

$proj = $solution.Projects | Where {$_.ProjectName -eq "build"}

你的工作正常了吗?我曾经遇到过类似的问题,但已经设法解决了。看见