【发布时间】: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