visual studio 2010 - python script to build multiple .msbuild files -
i new in python apologise rookie mistakes :)
i need write python script sets environment visual studio, creates temporary workspace, checks out latest version tfs , runs multiple .msbuild files under single directory , saves output log file.
i came script not working:
import subprocess command = "cmd.exe /c dir c:\\" all_logs = [] def run_cmd(command): """run command , print output""" print 'running: "%s"' % command print 'working dir: %s' % os.getcwd() print 'env params: %s' % os.environ p = subprocess.popen(command, shell=true, stdin=subprocess.pipe, stdout=subprocess.pipe, stderr=subprocess.stdout) out, err = p.communicate() print 'output: %s' % out print 'error: %s' % err all_logs.append(out) def set_env_params(): os.environ['path'] = os.environ['path'] + r';c:\program files (x86)\microsoft visual studio 10.0\vc' def run_tasks(): #get variables #set env parameters set_env_params() #source code checkout #script run_cmd('tf c:\users\username\documents\tfs /recursive') run_cmd('msbuild.exe c:/users/username\documents\tfs\buildscripts/msbuild/libraries.msbuild') run_cmd('msbuild.exe c:\users\username\documents\tfs\buildscripts/msbuild/pex.msbuild') run_cmd('msbuild.exe c:\users\username\documents\tfs\buildscripts/msbuild/dhsati.msbuild') run_cmd('msbuild.exe c:\users\username\documents\tfs\buildscripts/msbuild/dhbati.msbuild') run_cmd('msbuild.exe c:\users\username\documents\tfs\buildscripts/msbuild/view.msbuild') run_cmd('msbuild.exe c:\users\username\documents\tfs\buildscripts/msbuild/datafeed.msbuild') run_cmd('msbuild.exe c:\users\username\documents\tfs\buildscripts/msbuild/apps.msbuild') run_cmd('msbuild.exe c:\users\username\documents\tfs\buildscripts/msbuild/misc.msbuild') run_cmd('msbuild.exe c:\users\username\documents\tfs\buildscripts/msbuild/sdp.msbuild') run_cmd('msbuild.exe c:\users\username\documents\tfs\buildscripts/msbuild/unittests.msbuild') def main(): print '### starting tasks ###' run_tasks() print '### finished tasks ###' if __name__ == '__main__': #to run if python script executed directly main()
the main issues have are: 1) setting env variables gor vs2010 not enough. in order cmd understand 'tf' commands need run vcvarsall.bat file.
2) if add 'start "c:\program files (x86)\microsoft visual studio 10.0\vc\vcvarsall.bat"' command, cmd opening, correct environment commands follow, in script, cannot inserted in new cmd.
i tried writing bat file, run script had same issue cmd processes.
questions:
1) there way run commands under single process?
2) best way me this?
Comments
Post a Comment