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

标签 powershell nuget

在我的 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)

我受阻,将不胜感激任何建议。

最佳答案

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

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

关于powershell - 使用 NuGet uninstall.ps 删除解决方案文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13918767/

相关文章:

用于将组从静态更改为动态的 Powershell AzureAD 脚本

powershell - 搜索事件查看器服务器 03 和 08 r2

.net - 在 .NET Standard 项目中使用包引用后,如何恢复引用 packages.config 中的 Nuget 包?

nuget - 在 Intranet 上使用 Nuget

powershell - 如何使用 New-Hardlink PowerShell PSCX 命令创建硬链接(hard link)

c# - 在 c# 中重新创建 Az.Connect-AzAccount

PowerShell 和 -contains 运算符

c# - NuGet 元数据包是否仅保留给 .net 核心?

nuget - 如何强制 nuget 采用最新版本的软件包?

c# - 如何在 NuGet 发布后更新 Visual Studio Team Services 上的 NuGet 包?