Build Azure DevOps CICD生成管道失败,错误为:未找到指定的命令或文件

Build Azure DevOps CICD生成管道失败,错误为:未找到指定的命令或文件,build,aws-lambda,azure-devops,azure-pipelines,aws-api-gateway,Build,Aws Lambda,Azure Devops,Azure Pipelines,Aws Api Gateway,我在Azure Devops中有一个CICD构建管道,用于构建.NET核心AWS API网关无服务器应用程序。管道正在使用托管的Windows 2019。失败的步骤是: steps: - task: AmazonWebServices.aws-vsts-tools.LambdaNETCoreDeploy.LambdaNETCoreDeploy@1 displayName: 'Build solution and generate CloudFormation template. ' in

我在Azure Devops中有一个CICD构建管道,用于构建.NET核心AWS API网关无服务器应用程序。管道正在使用托管的Windows 2019。失败的步骤是:

steps:
- task: AmazonWebServices.aws-vsts-tools.LambdaNETCoreDeploy.LambdaNETCoreDeploy@1
  displayName: 'Build solution and generate CloudFormation template. '
  inputs:
    awsCredentials: 'AWS - Development (Infrastructure)'
    regionName: 'ap-southeast-2'
    command: deployServerless
    packageOnly: true
    packageOutputFile: '$(Build.ArtifactStagingDirectory)\serverless-output.yaml'
    lambdaProjectPath: testapi/LCSApi.csproj
    s3Bucket: 'api-dev-xxxxxxxx-s3'
    s3Prefix: 'azure_devops_builds/lcs/'
    additionalArgs: '-template serverless.template '
我从错误中得到的信息如下:

Beginning Serverless Deployment
Performing package-only build of serverless application, output template will be placed in D:\a\1\a\serverless-output.yaml
"C:\Program Files\dotnet\dotnet.exe" lambda package-ci -ot D:\a\1\a\serverless-output.yaml --region ap-southeast-2 --s3-bucket api-dev-xxxxxx-s3 --s3-prefix azure_devops_builds/lcs/ --disable-interactive true -template serverless.template
Could not execute because the specified command or file was not found.
Possible reasons for this include:
  * You misspelled a built-in dotnet command.
  * You intended to execute a .NET Core program, but dotnet-lambda does not exist.
  * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.

##[error]Error: The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 1
Finishing: Build solution and generate CloudFormation template.

但是,如果我在这次故障后直接重新运行管道,它工作正常。此外,它并不总是因此错误而失败。大约70-80%的时间管道工作正常。这可能是什么?我如何解决它?

您可以尝试在您的步骤之前添加以下内容:

powershell:|
dotnet工具安装--全局Amazon.Lambda.Tools--版本3.1.1
dotnet工具更新-g Amazon.Lambda.Tools

请将variable system.debug设置为True,以检查日志中是否有更多信息。另外,你什么时候有过这个问题?您以前是否遇到过此类问题?此问题是否有更新?Krzysztof Madej的建议对你有帮助吗?嗨,Cece,我以前有过这个问题,它是间歇性的。我今天已经添加了Krzysztof的建议,并将进行监控。任何更新,请告知我们。如果Krzysztof Madej的建议对你有帮助的话,你可以,这对阅读这篇文章的其他社区成员是有益的。你的问题进展如何?