JD.MSBuild.Fluent 1.3.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package JD.MSBuild.Fluent --version 1.3.0
                    
NuGet\Install-Package JD.MSBuild.Fluent -Version 1.3.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="JD.MSBuild.Fluent" Version="1.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="JD.MSBuild.Fluent" Version="1.3.0" />
                    
Directory.Packages.props
<PackageReference Include="JD.MSBuild.Fluent" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add JD.MSBuild.Fluent --version 1.3.0
                    
#r "nuget: JD.MSBuild.Fluent, 1.3.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package JD.MSBuild.Fluent@1.3.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=JD.MSBuild.Fluent&version=1.3.0
                    
Install as a Cake Addin
#tool nuget:?package=JD.MSBuild.Fluent&version=1.3.0
                    
Install as a Cake Tool

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .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