【问题标题】:Running Python script to deploy from MSBuild运行 Python 脚本以从 MSBuild 部署
【发布时间】:2014-04-04 18:15:32
【问题描述】:

我有一个 python 脚本正在做一些部署。 我想从 msbuild 运行该脚本并获取输出以防它通过或失败。 那么,如何与 msbuild 的 status 和错误文本进行通信? 我想在构建服务器上显示结果。 我必须使用 python 2.7,不能使用 3.x

【问题讨论】:

    标签: python-2.7 deployment msbuild


    【解决方案1】:

    使用 Exec 任务和capture it's output 运行命令。例如:

    <Target Name="GetPythonOutput">
    
      <PropertyGroup>
        <PyCommand>/path/to/python.exe -a /path/to/pthonfile</PyCommand>
        <TempFile>ExecTempFile</TempFile>
      </PropertyGroup>
    
      <Exec Command="$(PyCommand) &gt; $(TempFile)" />
    
      <ReadLinesFromFile File="$(TempFile)">
        <Output TaskParameter="Lines" ItemName="PyOutput"/>
      </ReadLinesFromFile>
      <Delete Files="$(TempFile)" />
    
      <Message Text="Python command output was: @(PyOutput)" />
    </Target>
    

    如果您使用的是 .Net 4.5,则情况会更好,因为 Exec can do most of the work for you

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-03
      • 2015-10-01
      • 2018-08-14
      • 1970-01-01
      • 2019-07-17
      • 2017-07-16
      • 2017-04-07
      • 2016-05-19
      相关资源
      最近更新 更多