Base16.Svg.BuildTasks 1.0.0

dotnet add package Base16.Svg.BuildTasks --version 1.0.0                
NuGet\Install-Package Base16.Svg.BuildTasks -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Base16.Svg.BuildTasks" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Base16.Svg.BuildTasks --version 1.0.0                
#r "nuget: Base16.Svg.BuildTasks, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Base16.Svg.BuildTasks as a Cake Addin
#addin nuget:?package=Base16.Svg.BuildTasks&version=1.0.0

// Install Base16.Svg.BuildTasks as a Cake Tool
#tool nuget:?package=Base16.Svg.BuildTasks&version=1.0.0                

Base16.Svg.BuildTasks

This package adds a custom build task that generates DrawingVisuals from SVG-files (Scalable Vector Graphics) which can then be directly used and referenced in WPF (Windows Presentation Foundation) applications.

This simplifies the process of creating a scalable UI using SVGs.

By adding a reference to this package all SVG-files in the referencing project will get a DrawingVisual generated with the same name as the SVG-file and a namespace that corresponds to the files location in the project structure.

Since this approach uses code-generation no additional runtime dependencies are required.

Getting Started

  1. Create a new WPF application and call it WpfSvgTestApp using either .NET Core or .NET Framework
  2. Add a reference to this NuGet-package
  3. Create a new folder in your project called Svg
  4. Add any SVG-file that you might have to the Svg folder (see known issues) and name the file MySvg.svg
  5. Verify that Build Action for the SVG-file is set to Svg Visual/SvgVisual
  6. Open MainWindow.xaml and replace the content with the following
<Window x:Class="WpfSvgTestApp.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfSvgTestApp"
        xmlns:Svg="clr-namespace:WpfSvgTestApp.Svg"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <Grid.Background>
            <VisualBrush Stretch="Uniform">
                <VisualBrush.Visual>
                    <Svg:MySvg />
                </VisualBrush.Visual>
            </VisualBrush>
        </Grid.Background>
    </Grid>
</Window>

  1. Compile and run the application

Known issues

  • If Svg Visual/SvgVisual is not available as Build Action after first adding this package simple unload and reload the project/solution
  • Symbols are currently not handled - only the "root visual" will get processed - this might change
  • "CSS type styles" are not handled
  • "Advanced masks" are not handled
  • Filenames are not mangled/normalized/cleaned - the name of the file will be used as the name of the generated DrawingVisual (excluding extension)
  • ...

Change log

Version 1.0.0

Initial release.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETFramework 4.7.1

    • No dependencies.
  • .NETStandard 2.1

    • 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.0 630 2/2/2020