JD.MSBuild.Fluent
1.2.0
See the version list below for details.
dotnet add package JD.MSBuild.Fluent --version 1.2.0
NuGet\Install-Package JD.MSBuild.Fluent -Version 1.2.0
<PackageReference Include="JD.MSBuild.Fluent" Version="1.2.0" />
<PackageVersion Include="JD.MSBuild.Fluent" Version="1.2.0" />
<PackageReference Include="JD.MSBuild.Fluent" />
paket add JD.MSBuild.Fluent --version 1.2.0
#r "nuget: JD.MSBuild.Fluent, 1.2.0"
#:package JD.MSBuild.Fluent@1.2.0
#addin nuget:?package=JD.MSBuild.Fluent&version=1.2.0
#tool nuget:?package=JD.MSBuild.Fluent&version=1.2.0
JD.MSBuild.Fluent
A strongly-typed, fluent DSL for authoring MSBuild packages in C#
Author MSBuild .props, .targets, and SDK assets using a strongly-typed fluent API in C#, then automatically generate 100% standard MSBuild XML during build. No more hand-editing XML - write refactorable, testable, type-safe C# code instead.
๐ Documentation
- Introduction - Project overview and core concepts
- Getting Started - Installation and quick start guide
- User Guides - Detailed tutorials and patterns
- API Reference - Complete API documentation
- Migration Guide - Convert existing XML to fluent API
โจ Features
- ๐ฏ Strongly-typed fluent API - IntelliSense, refactoring, compile-time validation
- ๐ Automatic build integration - Generate MSBuild assets during
dotnet build, no CLI required - ๐ฆ Full NuGet layout support -
build/,buildTransitive/, andSdk/folders - ๐ง XML scaffolding - Convert existing XML to fluent code with
jdmsbuild scaffold - โ Production-tested - Validated against real-world MSBuild packages
- ๐ Deterministic output - Consistent XML generation for meaningful diffs
Quick Start
1. Install the package
<PackageReference Include="JD.MSBuild.Fluent" Version="*" />
2. Define your MSBuild assets in C#
using JD.MSBuild.Fluent;
using JD.MSBuild.Fluent.Fluent;
namespace MySdk;
public static class DefinitionFactory
{
public static PackageDefinition Create() => Package.Define("MySdk")
.Props(p => p
.Property("MySdkEnabled", "true")
.Property("MySdkVersion", "1.0.0"))
.Targets(t => t
.Target("MySdk_Hello", target => target
.BeforeTargets("Build")
.Condition("'$(MySdkEnabled)' == 'true'")
.Message("Hello from MySdk v$(MySdkVersion)!", "High")))
.Pack(o => {
o.BuildTransitive = true;
o.EmitSdk = true;
})
.Build();
}
3. Build your project
MSBuild assets are automatically generated during build and packaged correctly:
- โ
build/MySdk.props - โ
build/MySdk.targets - โ
buildTransitive/MySdk.propsand.targets(if enabled) - โ
Sdk/MySdk/Sdk.propsandSdk.targets(if SDK enabled)
No CLI required! Just build and pack:
dotnet build
dotnet pack
Optional: Configure generation
<PropertyGroup>
<JDMSBuildFluentGenerateEnabled>true</JDMSBuildFluentGenerateEnabled>
<JDMSBuildFluentDefinitionType>MySdk.DefinitionFactory</JDMSBuildFluentDefinitionType>
<JDMSBuildFluentOutputDir>$(MSBuildProjectDirectory)\msbuild</JDMSBuildFluentOutputDir>
</PropertyGroup>
๐ Migrate from XML
Convert existing MSBuild XML files to fluent API:
# Install CLI tool
dotnet tool install -g JD.MSBuild.Fluent.Cli
# Scaffold from existing XML
jdmsbuild scaffold --xml MyPackage.targets --output DefinitionFactory.cs --package-id MyCompany.MyPackage
Before (XML):
<Project>
<PropertyGroup>
<MyPackageVersion>1.0.0</MyPackageVersion>
</PropertyGroup>
<Target Name="Hello" BeforeTargets="Build">
<Message Text="Hello from MyPackage v$(MyPackageVersion)!" Importance="High" />
</Target>
</Project>
After (Fluent C#):
public static PackageDefinition Create()
{
return Package.Define("MyPackage")
.Targets(t =>
{
t.PropertyGroup(null, group =>
{
group.Property("MyPackageVersion", "1.0.0");
});
t.Target("Hello", target =>
{
target.BeforeTargets("Build");
target.Message("Hello from MyPackage v$(MyPackageVersion)!", "High");
});
})
.Build();
}
Now you can refactor, test, and maintain your MSBuild logic like regular C# code!
๐ฏ Why JD.MSBuild.Fluent?
Problem: Hand-editing MSBuild XML is painful
- โ No IntelliSense or type safety
- โ No refactoring support
- โ Hard to test and validate
- โ Copy-paste leads to duplication
- โ Difficult to review diffs
Solution: Write C# instead
- โ Strongly-typed API with full IntelliSense
- โ Refactoring support - rename, extract, move
- โ Unit testable - validate logic before publishing
- โ DRY principle - reuse patterns across targets
- โ Better diffs - meaningful C# changes instead of XML noise
- โ Automatic generation - integrated into build pipeline
๐ฆ CLI Tool (Optional)
The CLI is optional for advanced scenarios. Most users don't need it since generation happens automatically during build.
# Install globally
dotnet tool install -g JD.MSBuild.Fluent.Cli
# Generate assets manually
jdmsbuild generate --assembly path/to/MySdk.dll --type MySdk.DefinitionFactory --output msbuild
# Generate built-in example
jdmsbuild generate --example --output artifacts/msbuild
# Scaffold from XML
jdmsbuild scaffold --xml MyPackage.targets --output DefinitionFactory.cs
๐ Output Layout
Generated files follow standard NuGet conventions:
build/
MySdk.props โ Applied to direct consumers
MySdk.targets โ Applied to direct consumers
buildTransitive/ โ (optional)
MySdk.props โ Applied transitively
MySdk.targets โ Applied transitively
Sdk/ โ (optional)
MySdk/
Sdk.props โ SDK-style project support
Sdk.targets โ SDK-style project support
๐งช Samples
samples/MinimalSdkPackage- Complete end-to-end example- Integration tests validate against JD.Efcpt.Build (real-world production package)
๐ Deterministic Output
The XML renderer produces deterministic, canonical output:
- Consistent property ordering
- Consistent item metadata ordering
- Consistent task parameter ordering
- Meaningful diffs across versions
๐ค Contributing
Contributions welcome! This project follows standard GitHub flow:
- Fork the repository
- Create a feature branch
- Make your changes with tests
- Submit a pull request
๐ License
๐ Related Projects
- JD.Efcpt.Build - EF Core Power Tools build integration (uses JD.MSBuild.Fluent)
- JD.MSBuild.Containers - Docker container build integration
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- 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.3.10 | 30 | 1/20/2026 |
| 1.3.9 | 139 | 1/20/2026 |
| 1.3.8 | 70 | 1/20/2026 |
| 1.3.7 | 101 | 1/20/2026 |
| 1.3.6 | 67 | 1/20/2026 |
| 1.3.5 | 70 | 1/20/2026 |
| 1.3.4 | 119 | 1/19/2026 |
| 1.3.3 | 73 | 1/18/2026 |
| 1.3.2 | 78 | 1/18/2026 |
| 1.3.1 | 80 | 1/18/2026 |
| 1.3.0 | 76 | 1/18/2026 |
| 1.2.3 | 73 | 1/18/2026 |
| 1.2.2 | 75 | 1/18/2026 |
| 1.2.1 | 78 | 1/18/2026 |
| 1.2.0 | 78 | 1/18/2026 |
| 1.1.2 | 77 | 1/18/2026 |
| 1.1.1 | 73 | 1/18/2026 |
| 1.1.0 | 93 | 1/18/2026 |
| 1.0.2 | 108 | 1/18/2026 |
| 1.0.1 | 80 | 1/18/2026 |
| 1.0.0 | 78 | 1/18/2026 |
| 0.2.0 | 83 | 1/18/2026 |
| 0.1.1 | 80 | 1/17/2026 |
| 0.1.0 | 80 | 1/17/2026 |