【问题标题】:Visual Studio 2010: use command line in a macro and write the output from the cmd to the output paneVisual Studio 2010:在宏中使用命令行并将 cmd 的输出写入输出窗格
【发布时间】:2011-11-10 20:57:53
【问题描述】:

我在 Visual Studio 2010 中使用宏来使用 .bat 做一些事情。 .bat 在命令行控制台中生成一些输出文本。 是否可以获取输出文本,将其显示在输出窗格中?

这是我的代码的一部分:

Sub CompileSCSS()

    Dim cmd As String

    cmd = String.Format("{0} watch {1} ", "C:\Ruby192\bin\Compass.bat", "C:\Workspace\MyProject\Solution\WebApp")
    Shell(cmd, AppWinStyle.NormalNoFocus, False)

    Write("Debug", "I want to write here the output of my .bat")

End Sub

只是为了上下文,并帮助您了解我的需求:

我的.bat 正在使用第三方工具来编译我的 SCSS(CSS 语法的扩展)并在文件中生成相应的 CSS。当编译器完成工作时,如果一切正常或有错误,它会给出输出。我想将消息信息直接集成到输出窗格中,然后自动编译我的 SCSS 文件(例如在 Ctrl+S 上),这样我几乎可以立即在浏览器上查看结果。

对不起我的英语,如果需要你可以纠正我:-)

【问题讨论】:

    标签: visual-studio-2010 visual-studio sass compass-sass visual-studio-macros


    【解决方案1】:

    只需将您的 .BAT 定义为 external tool。它有一个选项可以在输出窗口中显示输出。然后你可以assign a keyboard shortcut for it。如果您仍需要从宏中调用它,请使用语法:

    DTE.ExecuteCommand("Tools.ExternalCommandX")
    

    其中 X 是您的外部工具的订单号。

    【讨论】:

      猜你喜欢
      • 2012-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-27
      • 2023-03-24
      • 1970-01-01
      • 2010-11-12
      相关资源
      最近更新 更多