Devlooped.SponsorLink
1.1.0
Prefix Reserved
dotnet add package Devlooped.SponsorLink --version 1.1.0
NuGet\Install-Package Devlooped.SponsorLink -Version 1.1.0
<PackageReference Include="Devlooped.SponsorLink" Version="1.1.0"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add Devlooped.SponsorLink --version 1.1.0
#r "nuget: Devlooped.SponsorLink, 1.1.0"
// Install Devlooped.SponsorLink as a Cake Addin #addin nuget:?package=Devlooped.SponsorLink&version=1.1.0 // Install Devlooped.SponsorLink as a Cake Tool #tool nuget:?package=Devlooped.SponsorLink&version=1.1.0
Integrate GitHub Sponsors into your libraries so that users can be properly linked to their sponsorship to unlock features or simply get the recognition they deserve for supporting your project.
SponsorLink for .NET allows you to integrate sponsorship checks in the build process itself, without affecting IDE/Editor performance or command line/CI builds. Learn more about SponsorLink for open source developers and the onboarding process.
NOTE: this package is intended for package authors. Downstream package consumers should get it transitively automatically to support the SponsorLink checks.
Usage
Add the following analyzer to an analyzer project you include in your package:
using Devlooped;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
namespace SponsorableLib;
[DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)]
class SponsorLinker : SponsorLink
{
public SponsorLinker() : base("[SPONSORABLE]", "[PROJECT]")
{ }
}
Replace SPONSORABLE
with your sponsor account login and PROJECT
with a recognizable
name of your project or library (i.e. ThisAssembly
or Moq
). Optionally, use the
base constructor overload receiving a SponsorLinkSettings
which offers many options
to customize the behavior of the analyzer.
Make sure you have installed the GitHub SponsorLink Admin app and have followed the onboarding steps.
We recommend using NuGetizer for packing your libraries, which provides the easiest integration with SponsorLink too. Simply add a project reference from your main library to the analyzer project and all packaging should Just Work. An example analyzer project referenced by your main library is typically just:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackFolder>analyzers/dotnet</PackFolder>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NuGetizer" Version="0.9.1" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.0.1" Pack="false" />
<PackageReference Include="Devlooped.SponsorLink" Version="[VERSION]" />
</ItemGroup>
</Project>
To only run the SponsorLink check when a consumer directly references you package, include a
buildTransitive
targets file with your package that surfaces the relevant package id to the
analyzer:
<Project>
<ItemGroup>
<SponsorablePackageId Include="[YOUR_PACKAGE_ID]" />
</ItemGroup>
</Project>
Learn more about SponsorLink NuGet integration.
How it works
When you ship a new version of your library including the above analyzer, the first build in an IDE/editor session will result in one of these three messages:
User does not have the GitHub SponsorLink (user) app installed in his personal account. Warning SL02:
User installed the app, but is not sponsoring the sponsorable account. Warning SL03:
User installed the app and is sponsoring:
NOTE: you can provide your own actions for the above scenarios, or simply configure the default behavior by tweaking the min/max amount of random waits introduced during builds. By default, the waits will range from 0 to 4000ms. Use to relevant constructor overload in combination with
SponsorLinkSettings.Create()
factory method to access all configurable options.
The goal of SponsorLink is to help make your project more sustainable, support your ongoing development and ensure your customers can depend on it in the long run!
Learn more about SponsorLink NuGet integration, in particular the section on properly packing to workaround the issue of forced transitiveness of analyzers in the .NET SDK.
Sponsors
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on Devlooped.SponsorLink:
Repository | Stars |
---|---|
devlooped/nugetizer
A simple to understand packing model for authoring NuGet packages
|
Version | Downloads | Last updated |
---|