davewilliams459
davewilliams459

Reputation: 1739

TFS Build process template: In Console app, executing Console.Writeline fails build

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.

enter image description here

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="[&quot;&quot;&quot;C:\app.exe&quot;&quot;&quot;]" 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="[&quot;Handle Error Build Error: &quot; + 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="[&quot;Build Message: &quot; + ErrorMessage]" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces"
        />

        <mtbwa:WriteBuildError sap2010:WorkflowViewState.IdRef="WriteBuildError_10" Message="[&quot;Build Error: &quot; + ErrorMessage]" />

      </Sequence>
    </ActivityAction>
  </mtbwa:InvokeProcess.OutputDataReceived>

Upvotes: 2

Views: 476

Answers (2)

Morten Frederiksen
Morten Frederiksen

Reputation: 5165

You can use a CodeActivity for logging. Description here: Send information to the build log

Upvotes: 1

Daniel Mann
Daniel Mann

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

Related Questions