Reputation: 851
I need to lower some custom analyzers severity from error to warning in my CI build. I prepared a proper .globalconfig file for this task. Now I need to make "dotnet build" call aware of this file. I created a CustomTargets.targets file:
<Project>
<Target Name="MyTarget" BeforeTargets="BeforeBuild">
<PropertyGroup>
<RunCodeAnalysis>false</RunCodeAnalysis>
<RunAnalyzersDuringBuild>true</RunAnalyzersDuringBuild>
<ErrorLog>$(TestRootPath)$(TargetFileName).sarif.json</ErrorLog>
</PropertyGroup>
<ItemGroup>
<GlobalAnalyzerConfigFiles Include="$(TestRootPath)\.globalconfig" />
</ItemGroup>
</Target>
</Project>
My dotnet build call looks as follows:
dotnet build MySolution.sln /verbosity:minimal /p:Configuration=Debug /p:CustomAfterMicrosoftCommonTargets=%CCNetWorkingDirectory%\CustomTargets.targets /p:TestRootPath=%CCNetWorkingDirectory%
With the above configuration I still keep getting errors for analyzers that should have severity lowered to warning. My .globalconfig file is correct, because when used inside Visual Studio, I see only warnings reported. What do I miss?
Upvotes: 2
Views: 357