【问题标题】:Control Visual Studio 2017 from command line/package manager/powershell从命令行/包管理器/powershell 控制 Visual Studio 2017
【发布时间】:2018-12-12 10:36:45
【问题描述】:

我知道 PowerShell 对象 $dte,但我想知道它们是否还有其他可能性来控制 Rebuild SolutionClean Solution 等操作?

由于我的 PowerShell 提示符始终打开(使用 Posh-Git、.etc),因此直接从 PS 控制台控制其他 Visual Studio 任务会很方便。

【问题讨论】:

    标签: powershell visual-studio-2017


    【解决方案1】:

    DTE documentation for SolutionBuild 有一些很容易转换为 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() 
    

    SolutionBuild 接口还有其他有趣的方法:Clean()Debug()Run()。 您可能已经知道,但控制台需要以管理员身份运行才能获得 DTE 句柄。

    【讨论】:

      猜你喜欢
      • 2019-05-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-21
      • 1970-01-01
      • 1970-01-01
      • 2021-08-21
      • 2016-11-05
      相关资源
      最近更新 更多