Search code examples
visual-studio-2017code-analysistfs-2015code-standards

Incorporating microsoft managed recommended rules in GIT TFS 2015


I tried using stylecop, but it is quite strict with lot of rules. I do not want to customize it by disabling certain rules. I want to document that I am using 'Microsoft managed recommended rules', which I used while coding in VS 2017.

I want to incorporate the same rules in Git build process TFS-2015. Should I do code standard analysis during build definition? If not, how else?

Any help would be greatly appreciated!


Solution

  • It's not able to do the code analysis in branch policies where you set number of reviews and merge strategies. Unless the reviews manually check the code and fail the review according to Microsoft managed recommended rules.

    If you want to apply Microsoft managed recommended rules to your code. Simply add /p:RunCodeAnalaysis=true to the MsBuild commandline additional arguments.

    For stylecop there is also a related build task, if you want use this, you could add it in your build pipeline.

    Finally just enable the Build validation in your master branch policy. Set a policy requiring changes in a pull request to build successfully with the protected branch before the pull request can be completed.

    enter image description here