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
Asked
Active
Viewed 1,883 times
1 Answers
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) > $(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