2

I have a python script that is doing some deployment. I want to run that script from msbuild and get the output in case it pass, or failed. So, how can I communicate to msbuild of the status , and the error text? I want to show the result on the build server. I have to use python 2.7, and cannot use 3.x

1 Answer 1

6

Run the command using the Exec task and capture it's output. For example:

<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>

If you are using .Net 4.5 things are better since Exec can do most of the work for you

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.