-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
26 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,34 @@ | ||
# .NET Sample | ||
# SponsorLink .NET Analyzer | ||
|
||
This sample contains an absolute minimal package that can be built and published to NuGet.org, | ||
which contains just an analyzer assembly that consumes the SponsorLink package for nuget authors. | ||
This is one opinionated implementation of [SponsorLink](https://devlooped.com/SponsorLink) | ||
for .NET projects leveraging Roslyn analyzers. | ||
|
||
It can be installed to a project by running the following dotnet command from the target | ||
project directory: | ||
It is intended for use by [devlooped](https://github.com/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. | ||
|
||
``` | ||
dotnet add package SponsorableLib --version 42.42.42-main.* -s https://pkg.kzu.io/index.json | ||
``` | ||
## Usage | ||
|
||
A project initializing from this template repo via [dotnet-file](https://github.com/devlooped/dotnet-file) | ||
will have all the sources cloned under `src\SponsorLink`. | ||
|
||
This will run the SponsorLink check with `https://github.com/sponsors/devlooped` for your | ||
locally configured git email on IDE/Editor full builds. | ||
Including the analyzer and targets in a project involves two steps. | ||
|
||
The sample contains two analyzers, one with simple SponsorLink settings and an advanced one, | ||
so you will get both running the sample check. | ||
1. Create an analyzer project and add the following property: | ||
|
||
The Analyzer folder contains the analyzer project, and the Tests project is set up to consume | ||
it and allow for easy debugging by just running the Analyzer as the startup project from | ||
Visual Studio (for example). | ||
```xml | ||
<PropertyGroup> | ||
... | ||
<CustomAfterMicrosoftCSharpTargets>$(MSBuildThisFileDirectory)..\SponsorLink\SponsorLink.targets</CustomAfterMicrosoftCSharpTargets> | ||
</PropertyGroup> | ||
``` | ||
|
||
2. Add a `buildTransitive\[PackageId].targets` file with the following import: | ||
|
||
> NOTE: after initial restore, it might be necessary to restart the IDE for the analyzer | ||
> assemblies to be properly resolved and loaded for debugging. | ||
```xml | ||
<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. |