Handlebars.MSBuild
1.0.1
dotnet add package Handlebars.MSBuild --version 1.0.1
NuGet\Install-Package Handlebars.MSBuild -Version 1.0.1
<PackageReference Include="Handlebars.MSBuild" Version="1.0.1"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add Handlebars.MSBuild --version 1.0.1
#r "nuget: Handlebars.MSBuild, 1.0.1"
// 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.
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.