Does Visual Studio for Mac support roslyn analyzers, especially Microsoft.CodeAnalysis.FxCopAnalyzers?
Asked
Active
Viewed 2,763 times
1 Answers
5
The analyzer nuget packages can be added to a project in XamarinStudio/VS2017 for mac but you need to manually edit the project files to add the ItemGroup.Analyser project items linking to the dlls. These do not install on a mac as the installers are provided as custom PowerShell install scripts in the nuget packages. Note you will need to maintain the sections manually when updating the analyzer packages or removing them.
Ex: I needed to add the following to the project file, to install the Microsoft.CodeQuality.Analyzers 2.6.0 and also reload the project file.
<ItemGroup>
<Analyzer Include="..\..\packages\Microsoft.CodeQuality.Analyzers.2.6.0\analyzers\dotnet\cs\Microsoft.CodeQuality.Analyzers.dll" />
<Analyzer Include="..\..\packages\Microsoft.CodeQuality.Analyzers.2.6.0\analyzers\dotnet\cs\Microsoft.CodeQuality.CSharp.Analyzers.dll" />
</ItemGroup>
Once added and the project is re-build I received the CA warnings from the project, and they were displayed in the standard errors pane.

mhail
- 66
- 2
-
Thank you for the answer. With .NET Standard projects all packages seem to be placed out of solution folder in one place. What worked for me is to copy required analyzers (and their dependencies) to some solution-level folder and reference them in the code. Also looks like VS4Mac does not try to use analyzers on next build if they fail (for example to load dependency). Clean and then build helps to restore the justice) – Alex Sorokoletov Nov 12 '18 at 18:14
-
https://github.com/SonarSource/sonarlint-visualstudio/issues/4212 – G Clovs May 12 '23 at 10:32