This is one opinionated implementation of SponsorLink for .NET projects leveraging Roslyn analyzers.
It is intended for use by devlooped projects, but can be used as a template for other sponsorables as well. Supporting arbitrary sponsoring scenarios is out of scope though, since we just use GitHub sponsors for now.
A project can include all the necessary files by using the dotnet-file tool and sync all files to a folder, such as:
dotnet file add https://github.com/devlooped/SponsorLink/tree/main/samples/dotnet/ src/SponsorLink/
Including the analyzer and targets in a project involves two steps.
- Create an analyzer project and add the following property:
<PropertyGroup>
...
<CustomAfterMicrosoftCSharpTargets>$(MSBuildThisFileDirectory)..\SponsorLink\SponsorLink.Analyzer.targets</CustomAfterMicrosoftCSharpTargets>
</PropertyGroup>
- Add a
buildTransitive\[PackageId].targets
file with the following import:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="Devlooped.Sponsors.targets"/>
</Project>
As long as NuGetizer is used, the right packaging will be done automatically.