Python, subprocess, devenv why no output?

I am creating a Visual Studio solution from a Python script. Everything works well, except that I cannot capture the output of the assembly.

p = subprocess.Popen(['devenv', 'solution.sln', '/build'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out, err) = p.communicate() ret = p.returncode 

Here both out and err always empty. This happens regardless of build success, as shown in p.returncode .

+6
python subprocess
source share
4 answers

Instead, you should create a solution with msbuild.exe that is designed to provide feedback to stdout and stderr. msbuild.exe is located in

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\msbuild.exe (to create the VS2005 solution) or C:\WINDOWS\Microsoft.NET\Framework\v3.5\msbuild.exe (to create the VS2008 solution)

Note that msbuild.exe does not accept the /build switch, for example devenv.exe .

+2
source share

Change it from 'devenv' to 'devenv.com'. Apparenty Popen first searches for .EXE, but the shell first searches for .COM. Switching to "devenv.com" worked for me.

devenv is significantly faster than msbuild for incremental builds. I just made a build with an updated project, which means that nothing should happen.

devenv 23 seconds msbuild 55 seconds.

+25
source share

Perhaps due to the fact that the running software is not written to stdout or stderr . Perhaps it records directly to the terminal / console .

If in this case you need win32 api calls to capture the output.

0
source share

Your problem is probably the same as the buffer buffer. Check this question for a good answer.

-2
source share

All Articles