ViHo.PackAsAnalyzer 1.0.1

<Sdk Name="ViHo.PackAsAnalyzer" Version="1.0.1" />                
For projects that support Sdk, copy this XML node into the project file to reference the package.

PackAsAnalyzer

MSBuild infrastructure support to include source generators (analyzers) in nuget packages.

Usage

  1. Add the Sdk element that uses the ViHo.PackAsAnalyzer msbuild sdk package in your repo root's Directory.Build.props file so that all projects have access to the functionality:
<Project>

  
  <Sdk Name="ViHo.PackAsAnalyzer" Version="1.0.1" />

</Project>
  1. Add a ProjectReference item that points from the packable library to the source generator project and add the PackAsAnalyzer metadata to it:
<ItemGroup>
  <ProjectReference Include="..\analyzer\analyzer.csproj"
                    ReferenceOutputAssembly="false"
                    PackAsAnalyzer="true" />
</ItemGroup>

ℹī¸ Note: If you also want to consume the source generator in your project (instead of just packaging it), add the OutputItemType=Analyzer metadata to the ProjectReference item.

Configuration

The following properties can be set in the analyzer project:

  • AnalyzerLanguage: For C# projects, set to cs, for Visual Basic projects, set to vb. Omit the property if the analyzer should apply to all assembly families.
  • AnalyzerRoslynVersion: If the analyzer requires a minimum version of the Roslyn version, set this metadata. As of time of writing, roslyn4.4 packages are available. If the analyzer should target the very latest version only, set the property to 4.4.

Example:


<PropertyGroup>
  <AnalyzerLanguage>cs</AnalyzerLanguage>
  <AnalyzerRoslynVersion>4.4</AnalyzerRoslynVersion>
</PropertyGroup>
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 16,014 11/28/2022
1.0.0 1,628 11/28/2022