Reputation: 1739
I have an TFS build with a Build Process Template (xaml) that calls a console application. Whenever the console app returns messages, i.e. Console.WriteLine("Starting Build")
, the build interprets this as an error and tfs marks the it as 'Partial Failure'.
How can I return a message to the build log from a console app that does not cause the build to fail? Should I look at another way to return messages from the console app that will display in the build log? Or do I have to use an external logging method such as writing to a database / log4net etc.
Update: The workflow I am changing was not using the InvokeProcess. I corrected this, and am getting an error message displayed and the build still fails. You can see below I am attempting to write the error as a "WriteBuildError" and "WriteBuildMessge". Only the WriteBuildError displays, and the build still fails. What am I missing?
<mtbwa:InvokeProcess DisplayName="InvokeProcess" FileName="["""C:\app.exe"""]" sap2010:WorkflowViewState.IdRef="InvokeProcess_3" Result="[ExitCode]">
<mtbwa:InvokeProcess.ErrorDataReceived>
<ActivityAction x:TypeArguments="x:String">
<ActivityAction.Argument>
<DelegateInArgument x:TypeArguments="x:String" Name="errOutput" />
</ActivityAction.Argument>
<mtbwa:WriteBuildError sap2010:WorkflowViewState.IdRef="WriteBuildError_9" Message="["Handle Error Build Error: " + ErrorMessage]" />
</ActivityAction>
</mtbwa:InvokeProcess.ErrorDataReceived>
<mtbwa:InvokeProcess.OutputDataReceived>
<ActivityAction x:TypeArguments="x:String">
<ActivityAction.Argument>
<DelegateInArgument x:TypeArguments="x:String" Name="stdOutput" />
</ActivityAction.Argument>
<Sequence DisplayName="Handle Output" sap2010:WorkflowViewState.IdRef="Sequence_40">
<Assign sap2010:WorkflowViewState.IdRef="Assign_3">
<Assign.To>
<OutArgument x:TypeArguments="x:String">[ErrorMessage]</OutArgument>
</Assign.To>
<Assign.Value>
<InArgument x:TypeArguments="x:String">[If(Not String.IsNullOrWhiteSpace(ErrorMessage), Environment.NewLine + ErrorMessage, "") + stdOutput]</InArgument>
</Assign.Value>
</Assign>
<mtbwa:WriteBuildMessage sap2010:WorkflowViewState.IdRef="WriteBuildMessage_6" Importance="[Microsoft.TeamFoundation.Build.Client.BuildMessageImportance.High]" Message="["Build Message: " + ErrorMessage]" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces"
/>
<mtbwa:WriteBuildError sap2010:WorkflowViewState.IdRef="WriteBuildError_10" Message="["Build Error: " + ErrorMessage]" />
</Sequence>
</ActivityAction>
</mtbwa:InvokeProcess.OutputDataReceived>
Upvotes: 2
Views: 476
Reputation: 5165
You can use a CodeActivity for logging. Description here: Send information to the build log
Upvotes: 1
Reputation: 59037
It's based off of the application's exit code. It's not the message that's causing the error, it's because the application is exiting with a code that isn't 0.
Upvotes: 0