JD.MSBuild.Fluent.Cli 1.3.10

There is a newer version of this package available.
See the version list below for details.
dotnet tool install --global JD.MSBuild.Fluent.Cli --version 1.3.10
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local JD.MSBuild.Fluent.Cli --version 1.3.10
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=JD.MSBuild.Fluent.Cli&version=1.3.10
                    
nuke :add-package JD.MSBuild.Fluent.Cli --version 1.3.10
                    

JD.MSBuild.Fluent

A strongly-typed, fluent DSL for authoring MSBuild packages in C#

NuGet License CI codecov Documentation

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

View Complete Documentation

โœจ 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/, and Sdk/ 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.props and .targets (if enabled)
  • โœ… Sdk/MySdk/Sdk.props and Sdk.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

๐Ÿ” 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:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes with tests
  4. Submit a pull request

๐Ÿ“„ License

MIT License

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
1.3.15 93 1/24/2026
1.3.14 95 1/24/2026
1.3.13 87 1/24/2026
1.3.12 83 1/24/2026
1.3.11 89 1/24/2026
1.3.10 87 1/20/2026
1.3.9 90 1/20/2026
1.3.8 86 1/20/2026
1.3.7 90 1/20/2026
1.3.6 86 1/20/2026
1.3.5 90 1/20/2026
1.3.4 89 1/19/2026
1.3.3 87 1/18/2026
1.3.2 88 1/18/2026
1.3.1 85 1/18/2026
1.3.0 87 1/18/2026
1.2.3 86 1/18/2026
1.2.2 95 1/18/2026
1.2.1 94 1/18/2026
1.2.0 90 1/18/2026
Loading failed