[英]Control Visual Studio 2017 from command line/package manager/powershell
I am aware of the PowerShell object $dte
, but I am wondering if their are other possibilities to control actions like Rebuild Solution
, Clean Solution
etc? 我知道PowerShell对象$dte
,但是我想知道它们是否还有其他可能性来控制诸如“ Rebuild Solution
,“ Clean Solution
等操作?
As my PowerShell prompt ist opened anyway all the time (using Posh-Git, .etc) it would be handy to control other Visual Studio Tasks straight from the PS console. 无论如何我的PowerShell提示ist一直都在打开(使用Posh-Git,.etc),直接从PS控制台控制其他Visual Studio任务会很方便。
The DTE documentation for SolutionBuild has some VB code that was pretty easy to translate to Powershell: SolutionBuild的DTE文档包含一些很容易转换为Powershell的VB代码:
$dte = [System.Runtime.InteropServices.Marshal]::GetActiveObject('VisualStudio.DTE')
$sb = $dte.Solution.SolutionBuild
$sb.SolutionConfigurations['Debug'].Activate #Or maybe you want 'Release'
$sb.Build()
The SolutionBuild interface has other interesting methods: Clean()
, Debug()
and Run()
. SolutionBuild接口还有其他有趣的方法: Clean()
, Debug()
和Run()
。 You were probably already aware, but the console needs to be running as Administrator to get the DTE handle. 您可能已经知道了,但是控制台需要以管理员身份运行才能获取DTE句柄。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.