5

This blog post is the only thing I have found that comes close to the problem but it doesn't explain how to configure the Deploy Using PS/DSC to run with the verbose option: http://nakedalm.com/create-log-entries-release-management/

I can get this Agent-based Release Template to run the script:

Write-Debug "debug"
Write-Output "output"
Write-Verbose "verbose"
Write-Warning "warning"

The drilling down into deployment log for this release provides a log with the lines:

output
WARNING: warning

If I add -verbose to the Arguments field I also get a "VERBOSE: verbose" line in the log.

This is great, but I need the access to the System Variables ($Stage, $BuildNumber, etc). When I create a vNext template to run the same script (instructions are here: http://www.visualstudio.com/en-us/get-started/deploy-no-agents-vs.aspx), the log reports:

Copying recursively from \\vsalm\Drops2\TestBuild\TestBuild_20130710.3 to c:\Windows\DtlDownloads\my vnext component succeeded.

It is nice that this copying operation succeeded and all, but I'd like my script's output to be in this log as well. Does anyone have any idea about configuring a "Deploy Using PS/DSC" action so that the powershell script output is captured by Release Management?

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
mrfelis
  • 736
  • 7
  • 18

2 Answers2

5

For a vNext Release Template, try Write-Verbose with a -verbose switch if you want to see the powershell script output in the logs.

Eg. Write-Verbose "Some text" -verbose

divyanshm
  • 6,600
  • 7
  • 43
  • 72
  • This works, but I have a try/catch block in my release, and after that no more messages are being written, while the actions in that part are performed just fine... – Nick Apr 02 '15 at 09:52
1

Allow me to shamelessly plug my own blog article about this subject, because I found that it's not easy to get a script that does everything right.

The following script skeleton ensures that stdout output is logged without empty lines, and that processing is halted on the first error, in which case both the error details and the stdout output upto that point are visible in MSRM:

function Deploy()
{
    $ErrorActionPreference = "Stop"

    try
    {
        #
        # Deployment actions go here.
        #
    }
    catch
    {
        # Powershell tracks all Exceptions that occured so far in $Error
        Write-Output "$Error"

        # Signal failure to MSRM:
        $ErrorActionPreference = "Continue"
        Write-Error "Error: $Error"
    }
}

pushd $Global:ApplicationPath
Deploy | Out-String | Write-Verbose -Verbose
popd

This is just the final result, the explanation behind it can be found here.

Leon Bouquiet
  • 4,159
  • 3
  • 25
  • 36