Reputation:
In my .NET Framework (C#) solution, I use some Roslyn analyzers, whose settings I tuned in an .editorconfig file.
When I build my solution locally in VS 2019, I get no warnings from the analyzers.
When I build the solution in an Azure DevOps pipeline task, Roslyn related warnings are generated:
It seems to me that the DevOps pipeline task ignores the settings in the .editorconfig file. How can I make the pipeline task consider the .editorconfig file settings?
Upvotes: 5
Views: 3978
Reputation: 156624
We ran into a similar problem today, and discovered that MSBuild 16.9 prioritizes code analysis ruleset
files over .editorconfig
files. So if your project refers to a ruleset that sets a rule to be an Error, but your editorconfig changes it to be a suggestion
or warning
, it will still treat things as an error.
Since Azure DevOps updated the version of MSBuild to 16.9, while we were still using 16.8, we had different behaviors on our local machines than what happened in our build pipeline.
Oddly enough, setting severity to none
in the editorconfig file still seems to prevent the analyzer from complaining.
Upvotes: 1
Reputation: 28176
How can I make the pipeline task consider the .editorconfig file settings?
We don't need to manually set anything about .editorconfig
in pipeline, it would work automatically when it's placed under project folder. I've just tested it both in local machine and build pipeline, it should work.
So you should:
1.Navigate to Azure Devops Repos to check if the .editorconfig
file exists in same folder with xx.csproj
file. Pay attention to the branch you choose, make sure the branch you use to run build pipeline do have the .editorconfig
file.
2.Check the content of .editorconfig
file, check if it contains statements like this:
# SA1633: File should have header
dotnet_diagnostic.SA1633.severity = none
Your .editorconfig
file won't suppress those warnings unless it contains this kind of definitions.
3.Try using different agents, I assume you're using self-agent. Which means you're calling your local VS instance to run the job and maybe there's something wrong with that. I suggest you can try running it with microsoft-hosted agent(choose windows-latest
), it works well in my side. Also, update your local VS to latest version if you continue to do it using self-agent.
4.Specify the version of nuget.exe, 4.4.0 is too old. Try using 5.3.1 and above.
Hope all above helps :)
Upvotes: 3