Matt W
Matt W

Reputation: 12424

How to write to the VSTS log output?

I have a piece of C# run during my VSTS Release task and I want it to write to the log output so I can see what it is doing, as I would have it write to the console on my local machine.

How can I write to the VSTS log output?

I have tried:

Console.WriteLine();
Debug.WriteLine();
testContext.WriteLine(); // from Microsoft.VisualStudio.TestTools.UnitTesting

Upvotes: 0

Views: 263

Answers (1)

Ryan Schlueter
Ryan Schlueter

Reputation: 2221

$oldOut = [Console]::Out
$newOut = New-Object IO.StringWriter
$coverage = new-object SQLCover.CodeCoverage ($connectionString, $databaseName)
try
{
   [Console]::SetOut($newOut)
   $coverage.Cover("exec tSQLt.RunAll")
 }
 finally
 {
    [Console]::SetOut($oldOut)
 }
 $output = 'Console output from DLL call: ' + $newOut.ToString()

Upvotes: 1

Related Questions