问题背景
我正在从事一个C#项目,该项目使用Azure DevOps进行CI。我有一个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'
}问题
目前,$LASTEXITCODE可以是0 (no errors),也可以是1 (error)。如果退出代码为0,则一切正常,Azure显示绿色的传递徽章;如果为1,Azure则显示红色的错误徽章。但是,当生成中有警告时,它们将显示在日志中,Azure显示绿色徽章。
目标
我的目标是让Azure在有警告时显示一个黄色/橙色警告徽章。这有可能吗?怎么可能?非常感谢您的时间!
尝试解决方案
在C#项目属性中,Warning level设置为4;因此,我尝试了对power shell脚本的修改,但是它没有成功。
& $buildTools $solution 4> 'warning.txt'用解决方案更新
多亏了D.J.'s answer!最后的构建行如下:
# $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"发布于 2018-11-19 12:00:36
https://stackoverflow.com/questions/53372774
复制相似问题