2012-12-17 6 views
5

W moim pakiecie Nuget, dodaję folder rozwiązanie wykorzystujące metodę pokazaną tutaj: https://stackoverflow.com/a/6478804/1628707usunąć foldery rozwiązanie wykorzystujące Nuget uninstall.ps

Oto mój kod, aby dodać folder rozwiązanie, w 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) 
} 

Teraz w Uninstall.ps, chcę usunąć folder rozwiązanie o nazwie "Build". Próbowałem następujące.

//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) 

Jestem zafascynowany i doceniam wszelkie sugestie.

+1

Dostałeś tę pracę? –

+0

Wystąpiły problemy z podobnym problemem, ale udało mi się go złamać. Zobacz [to] (http://stackoverflow.com/questions/17769227/remove-project-from-solution-via-package-manager-console/28483691#28483691) – AHowgego

Odpowiedz

1

Nie wiem, dlaczego pozycja jest trudna, ale inny sposób to zrobić byłoby:

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