简体   繁体   English

从命令行/程序包管理器/ PowerShell控制Visual Studio 2017

[英]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: SolutionBuildDTE文档包含一些很容易转换为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.

相关问题 如何通过PowerShell或命令行运行Visual Studio 2017程序包管理器命令 - How to run Visual Studio 2017 Package Manager commands through PowerShell or command line 在Visual Studio Nuget包管理器控制台中中止“unclosed”powershell命令 - Aborting an “unclosed” powershell command in Visual Studio Nuget Package manager console Powershell包含在Visual Studio中的程序包管理器控制台中的项目中 - Powershell Include In Project From Package Manager Console In Visual Studio 如何在 Visual Studio 中配置包管理器控制台使用的 powershell 版本? - how to configure the powershell version used by the package manager console in visual studio? 在扩展中以编程方式访问visual studio的powershell控制台(包管理器控制台) - Access the powershell console (package manager console) of visual studio programmatically in an extension 如何在 Visual Studio 外使用包管理器控制台 powershell - How to use Package Manager Console powershell outside visual studio PowerShell:从 Visual Studio Code 运行脚本有效,从 PS 命令行运行失败 - PowerShell: Running Script from Visual Studio Code Works, Running from PS Command Line Fails Visual Studio 2017-无法初始化Powershell主机 - Visual Studio 2017 - Unable to initialize powershell host 在 Visual Studio 2017 中更新 PowerShell 版本 - Update PowerShell version in Visual Studio 2017 使用Visual Studio中的命令行 - Using the command line from within Visual Studio
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM