Handlebars.MSBuild 1.0.1

dotnet add package Handlebars.MSBuild --version 1.0.1                
NuGet\Install-Package Handlebars.MSBuild -Version 1.0.1                
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="Handlebars.MSBuild" Version="1.0.1">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Handlebars.MSBuild --version 1.0.1                
#r "nuget: Handlebars.MSBuild, 1.0.1"                
#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 Handlebars.MSBuild as a Cake Addin
#addin nuget:?package=Handlebars.MSBuild&version=1.0.1

// Install Handlebars.MSBuild as a Cake Tool
#tool nuget:?package=Handlebars.MSBuild&version=1.0.1                

Handlebars.MSBuild

Adds a custom MSBuild Task for transforming Handlebars Templates as part of the build process. Define your templates that you want to transform define HandlebarsTemplate items.

<Project>
    <ItemGroup>
        <HandlebarsTemplate Include="/AssemblyMetadata.hbs"/>
    </ItemGroup>
</Project>

You can define your templates as files on disk

{{! AssemblyMetadata.hbs}}
public static class AssemblyMetadata
{
    public static readonly string Name = {{MSBuildProjectName}};
    public static readonly Version Version = new Version({{Version}});
}

Properties

There is a wide range of properties that are already exposed but you can also define your own.

<ItemGroup>
    <HandlebarsProperty Include="Name" Value="John Smith"/>
</ItemGroup>

Then you can use this value in your template.

Hello {{Name}}, Nice to meet you!

Export

Output Directory

At this point no files will be generated as defining the templates only makes the custom task populated the metadata TransformedTemplate. You can either do what you want this this or use one of the following export features.

<Project>
    <ItemGroup>
        <HandlebarsTemplate 
            Include="/AssemblyMetadata.hbs" 
            OutputPath="AssemblyMetadata.cs"/>
    </ItemGroup>
</Project>

Writes the generated template to the bin directory using the given name.

NuGet Package

<Project>
    <ItemGroup>
        <HandlebarsTemplate 
            Include="/AssemblyMetadata.hbs" 
            Pack="True"
            PackagePath="Build/AssemblyMetadata.cs"/>
    </ItemGroup>
</Project>

Adds the generated output to the NuGet package that will be generated.

Compilation

<Project>
    <ItemGroup>
        <HandlebarsTemplate 
            Include="/AssemblyMetadata.hbs" 
            AddToCompilation="True" />
    </ItemGroup>
</Project>

This will add the generated file to the compilation process.

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 79 1/19/2025
1.0.0 70 1/12/2025
0.0.1 70 1/12/2025