Litee / SolutionCop

Tool for static analysis of Visual Studio solutions
Apache License 2.0
23 stars 3 forks source link

SolutionCop and SolutionCop.MSBuild overview

SolutionCop is a tool for analyzing Visual Studio solutions and projects. It covers the gap between FxCop (static analysis of assemblies) and StyleCop (static analysis of source code) and allows to do checks like lost files or unused NuGet packages. This tool is successfully used in several big .NET projects and saved me a lot of time.

SolutionCop.MSBuild allows to run SolutionCop checks during project compilation and detect issues earlier.

Build status

Supported rules - see more details for each rule by clicking its name

How to use SolutionCop

  1. Install SolutionCop via command line NuGet.exe Install SolutionCop or (for brave ones) via NuGet.exe Install SolutionCop -Prerelease.
  2. Launch SolutionCop once in command line: SolutionCop.exe -s MySolution.sln it will automatically create SolutionCop.xml file next to MySolution.sln. All rules in this config file will be disabled. Now you can enable rules in config file and launch SolutionCop checks:
SolutionCop.exe -s MySolution.sln -c SolutionCop.xml [-b TeamCity] [--build-server-no-success-messages]

I recommend to enabled rules gradually, especially if you have large project.

How to use SolutionCop.MSBuild

  1. Install SolutionCop (see instruction above) and generate rules for your solution
  2. Install SolutionCop.MSBuild NuGet package into every VS project you want to check and watch for errors in build output. Some notes:
    • SolutionCop.MSBuild doesn't allow to specify path to config file - instead it looks for SolutionCop.xml file in parent folders starting with folder where .csproj file is defined. Once config file is found logic is the same as in SolutionCop.
    • SameNuGetPackageVersions rule won't work in SolutionCop.MSBuild because tool processes each project separately, so has no chance to compare package versions between different projects.
    • To see more detailed output select verbose MSBuild output level in VS settings

TODO - Rules (in priority order)

TODO - Other