在我的NuGet包中,我使用这里展示的方法添加解决方案文件夹:https://dev59.com/KGw15IYBdhLWcg3wqNuM#6478804
以下是我在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)
我陷入困境,希望能获得任何建议。