bwets.Sharpliner.Extensions
0.1.4
dotnet add package bwets.Sharpliner.Extensions --version 0.1.4
NuGet\Install-Package bwets.Sharpliner.Extensions -Version 0.1.4
<PackageReference Include="bwets.Sharpliner.Extensions" Version="0.1.4" />
<PackageVersion Include="bwets.Sharpliner.Extensions" Version="0.1.4" />
<PackageReference Include="bwets.Sharpliner.Extensions" />
paket add bwets.Sharpliner.Extensions --version 0.1.4
#r "nuget: bwets.Sharpliner.Extensions, 0.1.4"
#:package bwets.Sharpliner.Extensions@0.1.4
#addin nuget:?package=bwets.Sharpliner.Extensions&version=0.1.4
#tool nuget:?package=bwets.Sharpliner.Extensions&version=0.1.4
bwets.Sharpliner.Extensions
Reusable, domain-free building blocks for authoring Azure DevOps pipelines with Sharpliner. Sharpliner lets you write pipelines as C# instead of YAML; this library adds the ergonomics that make a large, strongly-typed pipeline codebase pleasant to write, read, and refactor:
- Typed template bases so each template has a plain-POCO parameter model, a typed
Reference()call-site factory, and compile-time-safeP(p => p.X)parameter references. - A parameter mapper that turns a POCO into an Azure DevOps
parameters:block. - Expression helpers for the compile-time functions (
coalesce,format,${{ each }}loops, …). - Typed variables that both declare themselves and hand out typed references.
- Conditional mapping-key records for the
${{ if … }}: key:idiom Sharpliner can't otherwise model. - 157 typed marketplace-task records generated from the official
task.jsondefinitions — every input is a typed property, and inputs with a closed allowed-value list become enums.
Everything here is generic. It carries no assumptions about any particular repository, naming convention, or product.
Install
dotnet add package bwets.Sharpliner.Extensions
Targets net10.0 and brings in Sharpliner transitively.
30-second example
using bwets.Sharpliner.Extensions;
using bwets.Sharpliner.Extensions.Tasks;
using Sharpliner;
using Sharpliner.AzureDevOps;
using Sharpliner.AzureDevOps.Expressions;
public sealed class InstallDotNetParameters
{
public string? Version { get; init; } // required (no default)
[Default("$(Agent.ToolsDirectory)/dotnet")] public string? InstallPath { get; init; }
}
public class InstallDotNet : TypedStepTemplate<InstallDotNet, InstallDotNetParameters>
{
public override TargetPathType TargetPathType => TargetPathType.RelativeToGitRoot;
public override string TargetFile => "pipelines/install-dotnet.yml";
public override AdoExpressionList<Step> Definition =>
[
new UseDotNetTask("Install .NET SDK")
{
PackageType = UseDotNetPackageType.Sdk, // typed enum from UseDotNet@2's task.json
Version = P(p => p.Version), // ${{ parameters.version }}
InstallationPath = P(p => p.InstallPath),
},
];
}
generates
parameters:
- name: version
type: string
- name: installPath
type: string
default: $(Agent.ToolsDirectory)/dotnet
steps:
- task: UseDotNet@2
displayName: Install .NET SDK
inputs:
packageType: sdk
version: ${{ parameters.version }}
installationPath: ${{ parameters.installPath }}
and another template consumes it with a compile-checked call site:
InstallDotNet.Reference(new() { Version = P(p => p.DotNetVersion) })
Documentation
| Guide | What it covers |
|---|---|
| Getting started | Install, the pieces, your first template + pipeline |
| Typed templates | TypedStepTemplate/Job/Stage/VariableTemplate/Pipeline, Reference(), P() |
| Parameters | POCO → parameters: mapping, [Default]/[ParamName]/[AllowedValues]/EmptyDefault, AdoValue<T>, ConditionalValue |
| Expressions | Expr, ExprNode, LoopItem and ${{ each }} loops |
| Variables | TypedVariable and its .Ref/.Compile/.Macro references |
| Conditional mapping keys | ConditionalPoolStage/Job, ConditionalContainerJob, NamedPool, ConditionalVariablesBlock |
| Typed task records | The 157 Tasks/ records and their input enums |
Samples
Runnable, compiled examples live in samples/ — a project that builds four progressive
definitions (step → job → stage → pipeline) and publishes their YAML to
samples/generated/ so the input C# and output YAML always stay in sync.
How it relates to Sharpliner
This is a pure add-on: every type here builds on Sharpliner's model (StepTemplateDefinition,
Stage, Job, AzureDevOpsTask, …) and produces ordinary Sharpliner definitions. You can mix these
helpers with plain Sharpliner freely, and drop down to raw Sharpliner any time.
License
MIT
| Product | Versions 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. |
-
net10.0
- Sharpliner (>= 1.8.16)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.