- Get link
- X
- Other Apps
Posted by
Sudheer Kumar Suggu
on
- Get link
- X
- Other Apps
Leprechaun is a powerful code generation framework for Sitecore templates. Let me provide you with some details about it:
What is Leprechaun?
- Leprechaun is a universal, open API for code generation from Rainbow serialized or Sitecore serialized Sitecore templates.
- Unlike traditional T4 templates, Leprechaun uses state-of-the-art Roslyn code generation technology.
- It’s designed for speedy generation without requiring Visual Studio.
Key Features:
- Flexibility: Leprechaun uses C# Script files as templates. If you’re familiar with C#, it’s straightforward to work with.
- Build-Time Execution: You can run Leprechaun at build-time, avoiding merge conflicts in large model files.
- Helix-Friendly: Most of Leprechaun’s configuration is based on files, making it Helix-friendly.
Getting Started to use Leprechaun:
Leprechaun can be run at build-time with a pre-build step or with CLI. Here Leprechaun version 2.2.2 is used for code generation.
you can refer here for latest version of Leprechaun nuget package
To install the tool at your solution root you need to execute the following command, you can use the dotnet tool:
- Globally:
dotnet tool install --global --no-cache Leprechaun.Cli
Locally (within a project): If your project doesn’t have
.config\\dotnet-tools.json
, create it and then run.- dotnet new tool-manifest-It will create entry of leprechaun version info as shown below.
dotnet tool install --no-cache Leprechaun.Cli - It will install the latest version of Leprechaun in local specific to solution root.
Leprechaun - Initial Configuration :
- Grab the version of
Leprechaun.config
associated with your version of Leprechaun from here and based on the version this file will change and download based on your version from releases. - I have configured the Leprechaun.config file for a project and can be find in my Git for your reference.
- Copy the Leprechaun.config file in solution repository.
- Grab a script template. Some pre-configured ones can be Leprechaun and based on the code gen framework we can only use that file and the same can be configured in the leprechaun config file.
Looking on how other developers can use this tool on their local?
The
dotnet tool restore
command is used to restore the tools specified in the dotnet-tools.json
file. These tools are typically global .NET Core CLI tools that you want to use across different projects. Only by running this command alone will have the developer environment is ready with Leprechaun installed.In my next blog, we can check on how to integrate the Leprechaun to the solution.
Happy Code Generation 😀😀
Comments
Post a Comment
Please do not enter any spam link in the comment box