Best way to integrate StyleCop with TFS CI

前端 未结 3 1160
醉话见心
醉话见心 2020-12-08 01:30

I\'ve been doing research on how to enable source analysis for the project I\'m working on and plan to use StyleCop. The setup I have is a TFS Server for source control, usi

相关标签:
3条回答
  • 2020-12-08 01:43

    Some points for using StyleCop in general:

    • You don't need to have StyleCop installed on your (or the build) machine - simply add StyleCop's binaries to your source control (about 1.5 MB of stuff)
    • Then simply add the relative reference to your project files, like this (I left out < and >):

      Import Project="..\..\lib\Microsoft StyleCop\Microsoft.StyleCop.Targets"

    • We treat all StyleCop warnings as errors using the StyleCopTreatErrorsAsWarnings setting in the project file.

    • For legacy projects, you can use the tool provided by Microsoft to automatically set all existing source files to ignore.
    • You can put the StyleCop settings file (Settings.StyleCop) in the root directory where your VS solution is (and of course place it under the source control). StyleCop knows how to find this file automatically (by loooking up the directory tree). This way you can have custom settings for each solution.
    • We turned off certain StyleCop rules which we think aren't very practical to follow.

    This way StyleCop will be integrated in your compile step and as such it will become a part of the CI build.

    0 讨论(0)
  • 2020-12-08 02:00

    Go to Visual Studio, right click Solution > Manage Nuget Packages > Install StyleCop.MSBuild.

    That's it =)

    0 讨论(0)
  • 2020-12-08 02:10

    We use the approach in the following articles successfully on a couple of projects...

    http://blogs.msdn.com/sourceanalysis/pages/source-analysis-msbuild-integration.aspx http://blogs.msdn.com/sourceanalysis/archive/2008/11/11/introducing-stylecop-on-legacy-projects.aspx

    basically you set a couple of environment variables up, reference them in all the .csproj files so that you can cater for different working directories for each individual developer, install the StyleCop MSBuild components on the build machine and you're off. No changes to the team build required.

    0 讨论(0)
提交回复
热议问题