I'm interested in using the Stylecop.Analyzers nuget package, because it integrates Stylecop with Roslyn and because of that builds will fail if they do not meet the defined requirements. The idea that I have is as follows:
I create a custom nuget package containing a stylecop.json file and a Stylecop.Analyzers.ruleset file, with the package having a dependency on Stylecop.Analyzers.
I am able to get this to work in a .Net Core 2 project if I add the mentioned files manually and make the following changes to the .csproj:
<PropertyGroup>
<CodeAnalysisRuleSet>Stylecop.Analyzers.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
and the following for the stylecop.json file:
<ItemGroup>
<AdditionalFiles Include="stylecop.json" />
</ItemGroup>
Now I would like to automate this with the Nuget package, so I can easily install and use this in a variety of solutions/projects. Unfortunately I am not able to do this.
The first problem I run into is that I'm unable to update the .csproj from a nuget package. I tried to do so by creating the folder structure mentioned in the following thread: Providing a code analysis ruleset to a .net core project through NuGet
This did not seem to do anything...
Next I tried to solve this by using a Powershell install script that transforms the .csproj. I cloned the following project on Github: https://github.com/FantasticFiasco/csproj-ignition that uses Powershell to update the csproj. I tested this and I did get it to work for .Net Framework projects, but unfortunately not for my .Net Core 2 project.
So in short: does anyone know how to transform the .csproj of a .Net Core 2 project through the installation of a nuget package or is this mission impossible?