ful*_*ckz 5 c# msbuild continuous-integration azure azure-devops
我正在开发一个使用 Azure DevOps for CI 的 C# 项目。我有一个 Power shell 文件,当项目推送到 Azure 时正在运行该文件。构建文件的相关部分是:
# $buildTools is the path to MSBuild.exe
# $solution is the path to the project's .sln file
& $buildTools $solution /t:Clean,Build /p:Configuration=Release,Platform=x86
if ($LASTEXITCODE -eq 0) {
Write-Host 'Build completed successfully!'
} else {
Write-Host '##vso[task.logissue type=error;]There were errors during the build of the application'
}
Run Code Online (Sandbox Code Playgroud)
目前,$LASTEXITCODE可以是0 (no errors)或1 (error)。如果退出代码为 0,一切正常,Azure 会显示绿色的通过徽章;如果是 1 Azure 将显示红色错误徽章。但是,当构建中出现警告时,它们会显示在日志中,并且 Azure 会显示绿色徽章。
我的目标是让 Azure 在出现警告时显示黄色/橙色警告徽章。这可能吗?如何实现?非常感谢您的宝贵时间!
在 C# 项目属性中,Warning level将其设置为4; 所以我尝试对 power shell 脚本进行修改,但是没有成功。
& $buildTools $solution 4> 'warning.txt'
Run Code Online (Sandbox Code Playgroud)
感谢DJ的回答!最终的构建线如下所示:
# $warningsFile is a path to a file that will contain all the warnings
& $buildTools $solution /t:Clean,Build /p:Configuration=Release,Platform=x86 /fl1 "/flp1:$warningsFile;warningsonly"
Run Code Online (Sandbox Code Playgroud)
您可以使用此-> https://learn.microsoft.com/en-us/visualstudio/msbuild/obtaining-build-logs-with-msbuild?view=vs-2017#save-the-log-output-to-多个文件并将所有警告写入日志文件,然后检查日志文件是否包含任何内容,然后使用这些命令将警告写入输出(https://github.com/Microsoft/azure-pipelines-tasks/blob/master /docs/authoring/commands.md)
| 归档时间: |
|
| 查看次数: |
8080 次 |
| 最近记录: |