Add StyleCop to your Visual Studio build

Add a file called Directory.Build.Props to your solution with the contents below.

<Project>
	<PropertyGroup>
		<TargetFramework>net7.0</TargetFramework>
	</PropertyGroup>

	<ItemGroup>
		<PackageReference Include="StyleCop.Analyzers" version="1.2.0-beta.435">
			<PrivateAssets>all</PrivateAssets>
			<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
		</PackageReference>
	</ItemGroup>
</Project>

Also add a .editorconfig to your solution to configure your code styling. The StyleCop analyzer and the .editorconfig file play together to configure your build process.

Share

Leave a Reply

Your email address will not be published. Required fields are marked *