パッケージ マネージャー コンソール内で powershell を使用して、ソリューションからプロジェクトを削除するスクリプトを作成しようとしていますが、驚くほど苦労しています。
プロジェクトを簡単に追加できます
PM> $dte.Solution.AddFromFile("C:\Dev\Project1.csproj")
今、私はプロジェクトを削除したいのですが、何も機能しません。
私は次のような多くのことを試しました:
PM> $project1 = Get-Project "Project1Name"
PM> $dte.Solution.Remove($project1)
>
引数 "0" を値 "System.__ComObject" で "Remove" に変換できません
type "EnvDTE.Project": "型の "System.__ComObject" 値を変換できません
「System.__ComObject#{866311e6-c887-4143-9833-645f5b93f6f1}」と入力
"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'.
他の組み合わせも試しましたが、明らかに車輪が回っています。提案をいただければ幸いです。