【问题标题】:Remove solution folders using NuGet uninstall.ps使用 NuGet uninstall.ps 删除解决方案文件夹
【发布时间】:2012-12-18 02:00:30
【问题描述】:

在我的 NuGet 包中,我使用此处显示的方法添加了一个解决方案文件夹: https://stackoverflow.com/a/6478804/1628707

这是我在 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)

我遇到了困难,如果有任何建议,我将不胜感激。

【问题讨论】:

  • 你搞定了吗?
  • 我遇到了类似的问题,但已经设法破解它。见this

标签: powershell nuget


【解决方案1】:

不知道为什么 Item 很困难,但另一种方法是:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-14
    • 2012-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-22
    相关资源
    最近更新 更多