Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x

- run: dotnet restore

- run: dotnet build --no-restore -c Release

- run: dotnet test --no-build -c Release
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Release

on:
push:
tags: ["v*"]

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x

- name: Extract version from tag
id: version
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"

- run: dotnet restore

- run: dotnet build --no-restore -c Release -p:Version=${{ steps.version.outputs.VERSION }}

- run: dotnet test --no-build -c Release

- name: Push to NuGet
run: dotnet nuget push "artifacts/pkg/Fluidify.${{ steps.version.outputs.VERSION }}.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: artifacts/pkg/Fluidify.${{ steps.version.outputs.VERSION }}.nupkg
64 changes: 63 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,63 @@
# Fluidify
# Fluidify

A modern alternative to T4 — an MSBuild task that processes [Fluid](https://github.com/sebastienros/fluid) (Liquid) template files at build time to generate code, configuration, or any other text output.

## Installation

```shell
dotnet add package Fluidify
```

Fluidify is a development dependency — it runs only at build time and adds nothing to your project's runtime output.

## Usage

Add `<Fluidify>` items to your project file. Each item points to a `.fluid` template, and any custom metadata you set becomes a template variable.

```xml
<ItemGroup>
<Fluidify Include="Models/Greeting.cs.fluid" Greeting="HELLO" />
<Fluidify Include="Config/appsettings.json.fluid" AppName="MyApp" Version="1.0.0" />
</ItemGroup>
```

Templates use standard [Liquid syntax](https://shopify.github.io/liquid/):

**Models/Greeting.cs.fluid**
```liquid
public static class Greeting
{
public const string Value = "{{ Greeting }}, World!";
}
```

Building the project renders each template before compilation. The output path is inferred by stripping the `.fluid` extension, so `Models/Greeting.cs.fluid` produces `Models/Greeting.cs`.

Fluidify works with any text format — C#, JSON, HTML, YAML, or anything else. The `.fluid` extension is just a convention; the template itself is plain text with Liquid tags.

### Custom output path

Use the `Destination` metadata to write the output to a different location:

```xml
<ItemGroup>
<Fluidify Include="Templates/report.html.fluid"
Destination="Output/report.html"
Title="Status Report"
Author="MyApp" />
</ItemGroup>
```

Relative paths are resolved from the project directory. Directories are created automatically.

## How it works

Fluidify registers an MSBuild target that runs before `CoreCompile`. For each `<Fluidify>` item it:

1. Parses the `.fluid` file using the Fluid template engine
2. Passes all item metadata (except `Destination`) as template variables
3. Writes the rendered output to the inferred or specified destination

## License

Apache-2.0
8 changes: 8 additions & 0 deletions src/Fluidify/Fluidify.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
<LangVersion>latest</LangVersion>
<PackageId>Fluidify</PackageId>
<Version>0.1.0</Version>
<Authors>stanoddly</Authors>
<Description>A modern alternative to T4 — an MSBuild task that processes Fluid (Liquid) template files at build time to generate code, configuration, or any other text output.</Description>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/stanoddly/Fluidify</PackageProjectUrl>
<RepositoryUrl>https://github.com/stanoddly/Fluidify</RepositoryUrl>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageTags>msbuild;codegen;liquid;fluid;template</PackageTags>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageOutputPath>$(MSBuildThisFileDirectory)../../artifacts/pkg</PackageOutputPath>
<IncludeBuildOutput>false</IncludeBuildOutput>
Expand All @@ -20,6 +27,7 @@

<ItemGroup>
<None Include="build\Fluidify.targets" Pack="true" PackagePath="build" Visible="false" />
<None Include="..\..\README.md" Pack="true" PackagePath="" Visible="false" />
</ItemGroup>

<PropertyGroup>
Expand Down