You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

寻找含Invoke-SafeCommand函数的可下载PowerShell NuGet模块

寻找包含Invoke-SafeCommand函数的NuGet PowerShell模块

我正在寻找可通过NuGet下载的PowerShell模块,要求该模块包含如下Invoke-SafeCommand函数:

function Invoke-SafeCommand {
    param (
        [ScriptBlock]$ScriptBlock
    )

    try {
        & $ScriptBlock
    }
    catch {
        Write-Host "An exception is thrown : $_"
        exit 1
    }

    if ($LASTEXITCODE -ne 0) {
        Write-Host "The command return this last exit code : $LASTEXITCODE"
        exit $LASTEXITCODE
    }
}

该函数用于检查所调用的C#控制台程序的退出码或异常。此PowerShell脚本将在Azure DevOps管道中运行,希望当C#控制台程序运行失败时,该脚本也能触发管道失败。

内容的提问来源于stack exchange,提问作者Sybaris

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.14 01:52:04