Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have batch file which takes latest code from TFS and build it. I want to copy build result (build success or failed) in mail. How to copy it ?. If have any idea please share.

I'm using following Command for build solution.

VB
REM set msBuildDir=%WINDIR%\Microsoft.NET\Framework\v3.5
set msBuildDir=%WINDIR%\Microsoft.NET\Framework\v4.0.30319

call %msBuildDir%\msbuild.exe  %ExePath%/MySolution.csproj /t:Clean;rebuild /p:Configuration=Debug /l:FileLogger,Microsoft.Build.Engine;logfile=Z:\PathToSaveFile/Compile_Log.log
Posted
Updated 30-Nov-14 17:16pm
v3

1 solution

First of all, remove "call" from the last line.
To redirect the output, use pipe: '>' redirects the output to file, '>>' does the same appending the output to the existing file. For example, suppose you have the batch file BuildMyProject.bat. Then redirection would look like
BuildMyProject some optional build parameters here > outputFile.txt

You did not explain how you are going to send your mail. If you want to do it programmatically, you will find the facilities for the redirection of the console application (that includes batch files).

[EDIT]

This is how you can do it in PowerShell:
$output = & BuildMyProject.bat some optional build parameters
Don't forget '&' after '='. (You will also need to take care of the location of the batch file or its full path name.) After this line is executed, the output of the batch file will be copied to the variable $output.

—SA
 
Share this answer
 
v4
Comments
SachinSutar 30-Nov-14 23:53pm    
I send mail by .ps1 file. I want to pass parameter to .ps1 file. So just want to get build result into some variable and pass it to powershell file.
Sergey Alexandrovich Kryukov 1-Dec-14 10:21am    
Please see my update to my answer. I tested this solution; it works.
—SA
SachinSutar 1-Dec-14 19:25pm    
Thanks
Sergey Alexandrovich Kryukov 1-Dec-14 22:50pm    
You are very welcome.
Good luck, call again.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900