在我的 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)
我受到了阻碍,将不胜感激任何建议。