2012-12-17 10 views
5

Nel mio pacchetto NuGet, aggiungo una cartella soluzione utilizzando il metodo illustrato qui: https://stackoverflow.com/a/6478804/1628707rimuovere le cartelle soluzione utilizzando NuGet uninstall.ps

Ecco il mio codice per aggiungere la cartella della soluzione, in 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) 
} 

Ora, in Uninstall.ps, voglio rimuovere la cartella della soluzione denominata "build". Ho provato il seguente.

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

Sono impotente e apprezzerò qualsiasi suggerimento.

+1

hai preso questo lavoro? –

+0

Avevo problemi con un problema simile ma sono riuscito a risolverlo. Vedi [this] (http://stackoverflow.com/questions/17769227/remove-project-from-solution-via-package-manager-console/28483691#28483691) – AHowgego

risposta

1

Non certo perché articolo è stato difficile, ma un altro modo per farlo potrebbe essere:

$proj = $solution.Projects | Where {$_.ProjectName -eq "build"} 
Problemi correlati