如何在 vNext 发布模板的部署日志中获取 powershell 脚本输出?
How do you get powershell script output in the deployment log for a vNext Release Template?
这篇博客 post 是我发现的唯一接近问题的内容,但它没有解释如何使用 PS/DSC 将部署配置为 运行详细选项:
http://nakedalm.com/create-log-entries-release-management/
我可以将此基于代理的发布模板获取到 运行 脚本:
Write-Debug "debug"
Write-Output "output"
Write-Verbose "verbose"
Write-Warning "warning"
深入了解此版本的部署日志提供了包含以下行的日志:
output
WARNING: warning
如果我将 -verbose 添加到 Arguments 字段,我还会在日志中得到一个 "VERBOSE: verbose" 行。
这很好,但我需要访问系统变量($Stage、$BuildNumber 等)。当我为 运行 相同的脚本创建 vNext 模板时(说明在这里:http://www.visualstudio.com/en-us/get-started/deploy-no-agents-vs.aspx),日志报告:
Copying recursively from \vsalm\Drops2\TestBuild\TestBuild_20130710.3 to c:\Windows\DtlDownloads\my vnext component succeeded.
很高兴这次复制操作成功了,但我希望我的脚本的输出也能出现在这个日志中。有没有人知道配置 "Deploy Using PS/DSC" 操作以便发布管理捕获 powershell 脚本输出?
对于 vNext 发布模板,如果您想在日志中查看 powershell 脚本输出,请尝试 Write-Verbose
和 -verbose 开关。
例如。 Write-Verbose "Some text" -verbose
请允许我厚颜无耻地插入my own blog article这个主题,因为我发现要获得一个一切正常的脚本并不容易。
以下脚本框架确保记录的标准输出输出没有空行,并且在出现第一个错误时停止处理,在这种情况下,错误详细信息和到目前为止的标准输出输出在 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
这只是最终结果,后面的解释可以参考here。
这篇博客 post 是我发现的唯一接近问题的内容,但它没有解释如何使用 PS/DSC 将部署配置为 运行详细选项: http://nakedalm.com/create-log-entries-release-management/
我可以将此基于代理的发布模板获取到 运行 脚本:
Write-Debug "debug"
Write-Output "output"
Write-Verbose "verbose"
Write-Warning "warning"
深入了解此版本的部署日志提供了包含以下行的日志:
output
WARNING: warning
如果我将 -verbose 添加到 Arguments 字段,我还会在日志中得到一个 "VERBOSE: verbose" 行。
这很好,但我需要访问系统变量($Stage、$BuildNumber 等)。当我为 运行 相同的脚本创建 vNext 模板时(说明在这里:http://www.visualstudio.com/en-us/get-started/deploy-no-agents-vs.aspx),日志报告:
Copying recursively from \vsalm\Drops2\TestBuild\TestBuild_20130710.3 to c:\Windows\DtlDownloads\my vnext component succeeded.
很高兴这次复制操作成功了,但我希望我的脚本的输出也能出现在这个日志中。有没有人知道配置 "Deploy Using PS/DSC" 操作以便发布管理捕获 powershell 脚本输出?
对于 vNext 发布模板,如果您想在日志中查看 powershell 脚本输出,请尝试 Write-Verbose
和 -verbose 开关。
例如。 Write-Verbose "Some text" -verbose
请允许我厚颜无耻地插入my own blog article这个主题,因为我发现要获得一个一切正常的脚本并不容易。
以下脚本框架确保记录的标准输出输出没有空行,并且在出现第一个错误时停止处理,在这种情况下,错误详细信息和到目前为止的标准输出输出在 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
这只是最终结果,后面的解释可以参考here。