|
1 | | -# .NET Sample |
| 1 | +# SponsorLink .NET Analyzer |
2 | 2 |
|
3 | | -This sample contains an absolute minimal package that can be built and published to NuGet.org, |
4 | | -which contains just an analyzer assembly that consumes the SponsorLink package for nuget authors. |
| 3 | +This is one opinionated implementation of [SponsorLink](https://devlooped.com/SponsorLink) |
| 4 | +for .NET projects leveraging Roslyn analyzers. |
5 | 5 |
|
6 | | -It can be installed to a project by running the following dotnet command from the target |
7 | | -project directory: |
| 6 | +It is intended for use by [devlooped](https://github.com/devlooped) projects, but can be |
| 7 | +used as a template for other sponsorables as well. Supporting arbitrary sponsoring scenarios |
| 8 | +is out of scope though, since we just use GitHub sponsors for now. |
8 | 9 |
|
9 | | -``` |
10 | | -dotnet add package SponsorableLib --version 42.42.42-main.* -s https://pkg.kzu.io/index.json |
11 | | -``` |
| 10 | +## Usage |
| 11 | + |
| 12 | +A project initializing from this template repo via [dotnet-file](https://github.com/devlooped/dotnet-file) |
| 13 | +will have all the sources cloned under `src\SponsorLink`. |
12 | 14 |
|
13 | | -This will run the SponsorLink check with `https://github.com/sponsors/devlooped` for your |
14 | | -locally configured git email on IDE/Editor full builds. |
| 15 | +Including the analyzer and targets in a project involves two steps. |
15 | 16 |
|
16 | | -The sample contains two analyzers, one with simple SponsorLink settings and an advanced one, |
17 | | -so you will get both running the sample check. |
| 17 | +1. Create an analyzer project and add the following property: |
18 | 18 |
|
19 | | -The Analyzer folder contains the analyzer project, and the Tests project is set up to consume |
20 | | -it and allow for easy debugging by just running the Analyzer as the startup project from |
21 | | -Visual Studio (for example). |
| 19 | +```xml |
| 20 | + <PropertyGroup> |
| 21 | + ... |
| 22 | + <CustomAfterMicrosoftCSharpTargets>$(MSBuildThisFileDirectory)..\SponsorLink\SponsorLink.targets</CustomAfterMicrosoftCSharpTargets> |
| 23 | + </PropertyGroup> |
| 24 | +``` |
| 25 | + |
| 26 | +2. Add a `buildTransitive\[PackageId].targets` file with the following import: |
22 | 27 |
|
23 | | -> NOTE: after initial restore, it might be necessary to restart the IDE for the analyzer |
24 | | -> assemblies to be properly resolved and loaded for debugging. |
| 28 | +```xml |
| 29 | +<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
| 30 | + <Import Project="Devlooped.Sponsors.targets"/> |
| 31 | +</Project> |
| 32 | +``` |
25 | 33 |
|
| 34 | +As long as NuGetizer is used, the right packaging will be done automatically. |
0 commit comments