This project uses NuGet to distribute custom analysis and style rules, so that consistency across projects can be mandated (and so that the rules may be easily updated over time). The major players are:
- EditorConfig file line ending / spacing settings
- StyleCop settings for source style, like linting
- FxCop aka
Code Analysis
settings for static analysis violations - Gendarme settings for static analysis violations
To ensure that your project is modified correctly, this package should only be installed from within Visual Studio using either the Nuget package manager dialog or the package manager console.
The simplest way to install in package manager console for all projects is:
Get-Project -All | % { Install-Package -ProjectName $_.Name -Id AnalysisRules }
Where AnalysisRules
is the name of the published package.
Additional updates should generally be performed in the same manner, as relative
paths to the package assets are written to the .csproj
files.
git
Well, the installation script modifies the .csproj
files to safely include
all relevant files. The installation has a basic heuristic that detects test
projects and varies the configuration accordingly.
-
For FxCop - tweaks to CodeAnalysis settings and ruleset config
CodeAnalysisPath
is configured to work properly on VS2012, VS2010 or on a build server where FxCop may be in it's own directory. It defaults to looking in this order as the project loads
$(DevEnvDir) - only works in current VS $(VS110COMNTOOLS) - VS 2012 $(VS100COMNTOOLS) - VS 2010 $(MSBuildProgramFiles32)\Microsoft Fxcop 10.0 $(ProgramFiles)\Microsoft Fxcop 10.0
CodeAnalysisRuleSet
sets toFxCopRulesTest.ruleset
orFxCopRules.ruleset
based on the projectRuleset
is eitherStandard
orTest
CODE_ANALYSIS
constant is set inDefineConstants
for any projects that are not DEBUGCodeAnalysisDictionary
is linked toCustomDictionary.xml
in this pkgFxCopPath
andFxCopRulesPath
are set likeCodeAnalysisPath
andCodeAnalysisRuleSet
for backward / cmd line compatibilityRunCodeAnalysis
is set toTrue
for the project
-
For StyleCop
Settings.StyleCop
is copied to the project directory, and links back to the file shipped in this package - varying based on the test heuristic- Individual project overrides may be placed in this Settings.StyleCop file as long as the link back to package file is maintained
-
For Gendarme
GendarmeConfigFilename
is set to thegendarme-rules.xml
file shipping with this packageGendarmeRuleset
is set toStandard
orTest
as appropriate- A
gendarme.ignore
file is copied to the projectsProperties
folder with some samples on how to ignore items for the particular project
-
For EditorConfig
- The
.editorconfig
file is copied into solution path IFF it isn't there - The settings use a 2 space (no TAB) indent with
CRLF
line endings
- The
This package serves as a basic blueprint, but you might not agree with our selections.
Create a fork of this repo, configure the rules as you see fit, and publish with the basic scaffolding we prescribe.
To push the package, from the source directory, using Powershell
.\NuGetPack.ps1 -APIKey $yourApiKey -Source https://yournuget.com
##TODO
- Test / Expose dependencies through NuGet and ensure project props compatible
- Gendarme - Can kick off Gendarme from MSBuild
- FxCop - currently no easy way to get FxCop installed outside of VS
- seems like something for Chocolatey, but would be better to concoct a Nuget tool package that lives in a sibling directory IMHO
- ASP.NET security FXCop rules - no means of distro right now
- StyleCop - provides all the MSBuild hooks
- Double-check that this runs OK under Jenkins - keep good on promises, right?
- Provide a system for project specific FxCop rule overloads
- Basic build server install instructions
- Include new VS2012 rules