小编Cha*_*att的帖子

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

在我的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)
}
Run Code Online (Sandbox Code Playgroud)

现在,在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 …
Run Code Online (Sandbox Code Playgroud)

powershell nuget

5
推荐指数
1
解决办法
532
查看次数

标签 统计

nuget ×1

powershell ×1