I\'ve run into a problem when upgrading a .NET 4.6 project to .NET Core 2.0. All our projects use a custom StyleCop ruleset which is provided by a NuGet package. The ruleset
The idea is to not try to deploy the file as content but add build logic to the NuGet package.
Make sure that the package is structured in the following way:
CustomRuleset.targets
)This structure causes the .targets file to be automatically imported into the consuming project by convention.
The .targets file should then contain:
$(MSBuildThisFileDirectory)custom.ruleset
This will cause the project's ruleset property to be overwritten to the location relative to the .targets file.
Note that this also applies to .net framework projects using the new PackageReference
style of NuGet packages (replacement of packages.config
) which is opt-in in VS 2017 (15.2+).