At this time, the code fix is not able to fully configure the newly-created stylecop.json file for use. This is tracked in bug report dotnet/roslyn#4655. In the mean time, users must manually perform the following additional steps after creating the stylecop.json file.
In Visual Studio 2017, 2019, and 2022:
- Select the file in Solution Explorer.
- In the Properties window, set the value for Build Action to:
- For most projects: AdditionalFiles
- For projects using the new project system, including .NET Core and .NET Standard projects: C# analyzer additional file.
In Visual Studio 2015 Update 3 and newer:
- Select the file in Solution Explorer.
- In the Properties window set the value for Build Action to AdditionalFiles.
In older versions of Visual Studio 2015:
-
Right click the project in Solution Explorer and select Unload Project. If you are asked to save changes, click Yes.
-
Right click the unloaded project in Solution Explorer and select Edit ProjectName.csproj.
-
Locate the following item in the project file.
<None Include="stylecop.json" />
-
Change the definition to the following.
<AdditionalFiles Include="stylecop.json" />
-
Save and close the project file.
-
Right click the unloaded project in Solution Explorer and select Reload Project.
Additional information about the content of stylecop.json is available in Configuration.md.