Svg.SourceGenerator.Skia is the build-time package that turns .svg additional files into generated C# classes exposing SKPicture content. It packages the Roslyn incremental generator used in this repository's samples and lets consuming projects compile SVG assets into code automatically.
Add the package reference:
<ItemGroup>
<PackageReference Include="Svg.SourceGenerator.Skia" Version="*" />
</ItemGroup>
Then add one or more SVG files as AdditionalFiles:
<ItemGroup>
<AdditionalFiles Include="Assets\Camera.svg"
NamespaceName="MyApp.Generated"
ClassName="Camera" />
<AdditionalFiles Include="Assets\Logo.svg"
NamespaceName="MyApp.Generated"
ClassName="Logo" />
</ItemGroup>
.svg files,For each .svg file, the generator emits a C# source file containing a generated class with:
Picture property,Draw(SKCanvas) method,If ClassName is not supplied, the generator falls back to Svg_<file-name>.
If NamespaceName is not supplied, the generator falls back to:
NamespaceName build property when set,Svg.Once the build runs, use the generated classes directly:
using MyApp.Generated;
var picture = Camera.Picture;
In Avalonia, pair it with Skia.Controls.Avalonia:
<SKPictureControl Picture="{x:Static local:Camera.Picture}" Stretch="Uniform" />
.svg files added as AdditionalFiles.NamespaceName can be configured per file or as a project-wide MSBuild property..props file is imported automatically.Svg.SourceGenerator.Skia.props explicitly, as shown in the sample project.