我试图在软件包管理器控制台中使用powershell来编写从解决方案中删除项目的脚本,我遇到了一个非常困难的时间.
我可以轻松地添加一个项目
PM> $dte.Solution.AddFromFile("C:\Dev\Project1.csproj")Run Code Online (Sandbox Code Playgroud)
现在我想删除一个项目,但无法获得任何工作.
我尝试了很多东西,包括:
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"."Run Code Online (Sandbox Code Playgroud)
PM> $project = [EnvDTE.Project] ($project1)
Cannot convert the "System.__ComObject" value of type
"System.__ComObject#{866311e6-c887-4143-9833-645f5b93f6f1}" …Run Code Online (Sandbox Code Playgroud)