AspBucket offers ASP.NET, C#, VB, Jquery, CSS, Ajax, SQL tutorials. It is the best place for programmers to learn

Tuesday 2 May 2017

How to integrate style cop in the project?

In this article I am going to discuss How to integrate style cop in the project? Please read the below content to enable the style cop in project.
Open Visual studio Open Package Manager Console from TOOLS > LIBRARY PACKAGE MANAGER menu
install-package stylecop.msbuild

The above command will download the latest stable required dlls and files and integrate style cop with your project. Build your project and any style-cop errors will be shown in the warnings section.

Now style cop is enabled in your project if you want to build solution successfully if all the style cop issues are fixed. Then you need to make changes in the project file ( .csproj).

Open the .crproj file in the notepad and find the first PropertyGroup section within the file add 
<StyleCopTreatErrorsAsWarnings>false</StyleCopTreatErrorsAsWarnings>
in the file. for example:
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
      <StyleCopTreatErrorsAsWarnings>false</StyleCopTreatErrorsAsWarnings>
    </PropertyGroup>
    <Error Condition="!Exists('..\packages\StyleCop.MSBuild.4.7.55.0\build\StyleCop.MSBuild.Targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\StyleCop.MSBuild.4.7.55.0\build\StyleCop.MSBuild.Targets'))" />
  </Target>

Now project will be successful if you fixed all style-cop issues.

0 comments :

Post a Comment

  • Popular Posts
  • Comments