问题
I've setup Static Code Analysis on my Visual Studio Team Services builds. I'm using the "MSBuild" build step for my solution and in the build logs it shows 999+ lines that start with ##[warning]
:
2017-11-09T13:52:34.7970784Z ##[warning]myfilename.cs(753,17): Warning CA2200: Re-throwing caught exception changes stack information.
When building with "system.debug" set to true, we also see that vso parses these warnings, and 999+ lines in the log show up like this:
2017-11-15T12:30:40.1964968Z ##[warning]myfilename.cs(28,33): Warning CS0109: The member 'Invoice.ColumnOptions' does not hide an accessible member. The new keyword is not required.
2017-11-15T12:30:40.1964968Z ##[debug]Processed: ##vso[task.logissue type=Warning;sourcepath=myfilename.cs;linenumber=28;columnnumber=33;code=CS0109;]The member 'XXX' does not hide an accessible member. The new keyword is not required.
I would expect that the 999+ static analysis warnings would show up somewhere in the build overview (i.e. https://MYSITE.visualstudio.com/MYPROJECT/_build/index?buildId=XXX&_a=summary&tab=details
). However it only shows 11 build warnings, nothing else. See also the screenshot below. How can I display the Static Code Analysis warnings in this build overview? Maybe even a summarised overview of the types of warnings that have triggered?
回答1:
After some months of working with VSTS, my experience is as follows;
- Code Analysis warnings will show up on the build summary
- VSTS will only show the first 11 warnings
- Thus, if the Code Analysis warnings are printed after 11 build warnings, they won't show up.
We've started using Build Quality Checks to fail the build when there are more warnings compared to the baseline.
回答2:
Yes, just part of warnings in build display in the Issues section of build summary.
The workaround is that you can upload the code analysis result file (xml) through Logging Commands (##vso[task.uploadsummary]local file path
)and the content shall be added to build/release summary (Below Work items linked to associated changes section)
- Add Powershell task
- Call logging command to upload code analysis result
For example:
param(
[string]$p
)
Write-Host "##vso[task.uploadsummary]$p"
Arguments:
-p $(Build.SourcesDirectory)\WebAppAzureProfile\bin\WebAppAzureProfile.dll.CodeAnalysisLog.xml
来源:https://stackoverflow.com/questions/47260437/show-code-analysis-warnings-in-vsts