Sto tentando di utilizzare powershell all'interno della console di Gestione pacchetti per scrivere la rimozione di un progetto da una soluzione e sto avendo un tempo sorprendentemente difficile.Rimuovere il progetto dalla soluzione tramite la console di Package Manager
posso facilmente aggiungere un progetto di
PM> $dte.Solution.AddFromFile("C:\Dev\Project1.csproj")
Ora voglio essere rimuovere un progetto e non può ottenere nulla al lavoro.
Ho provato un certo numero di cose tra cui:
PM> $project1 = Get-Project "Project1Name"
PM> $dte.Solution.Remove($project1)
>
Cannot convert argument "0", with value: "System.__ComObject", for "Remove" to
type "EnvDTE.Project": "Cannot convert the "System.__ComObject" value of type
"System.__ComObject#{866311e6-c887-4143-9833-645f5b93f6f1}" to type
"EnvDTE.Project"."
PM> $project = Get-Interface $project1 ([EnvDTE.Project])
PM> $dte.Solution.Remove($project)
Cannot convert argument "0", with value: "System.__ComObject", for "Remove" to
type "EnvDTE.Project": "Cannot convert the "System.__ComObject" value of type
"NuGetConsole.Host.PowerShell.Implementation.PSTypeWrapper" to type
"EnvDTE.Project"."
PM> $project = [EnvDTE.Project] ($project1)
Cannot convert the "System.__ComObject" value of type
"System.__ComObject#{866311e6-c887-4143-9833-645f5b93f6f1}" to type
"EnvDTE.Project".
PM> $solution2 = Get-Interface $dte.Solution ([EnvDTE80.Solution2])
PM> $solution2.Remove($project1)
Exception calling "Remove" with "1" argument(s): "Exception calling
"InvokeMethod" with "3" argument(s): "Object must implement IConvertible.""
PM> $dte2 = Get-Interface $dte ([EnvDTE80.DTE2])
PM> $dte2.Solution.Remove($project)
Method invocation failed because [System.Object[]] doesn't contain a method
named 'Remove'.
ho provato altre combinazioni, ma sono chiaramente girare le ruote. Apprezzo qualsiasi suggerimento.
Hai funzionato? Ho un bisogno simile. –