Skip to content

Commit 23b2174

Browse files
committed
Add targets project
1 parent 3016345 commit 23b2174

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

build.cmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@echo Off
2+
dotnet run --project build\targets -- %*

build/targets/Program.cs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using System;
2+
using System.Linq;
3+
using System.Threading.Tasks;
4+
using ProcNet;
5+
using static Bullseye.Targets;
6+
using static ProcNet.Proc;
7+
8+
namespace targets
9+
{
10+
public class Program
11+
{
12+
private static string T(string t) => t.Replace("Target", "").ToLowerInvariant();
13+
private static string[] D(params string[] ts) => DependsOn(ts.Select(T).ToArray());
14+
private static void Chain(string t, params string[] ts) => Target(T(t), D(ts));
15+
private static void T(string t, Action a, params string[] ts) => Target(T(t), D(ts), a);
16+
private static void TAsync(string t, Func<Task> a, params string[] ts) => Target(T(t), D(ts), a);
17+
18+
public static async Task<int> Main(string[] args)
19+
{
20+
Chain(nameof(Default), nameof(DrinkTeaTarget), nameof(GitStatus));
21+
22+
T(nameof(MakeTea), MakeTea);
23+
24+
T(nameof(DrinkTeaTarget), DrinkTeaTarget.Exec, nameof(MakeTea));
25+
26+
T(nameof(GitStatus), GitStatus.Execute);
27+
28+
try
29+
{
30+
await RunTargetsAsync(args);
31+
}
32+
catch (ProcExecException ex)
33+
{
34+
return ex.ExitCode ?? 1;
35+
}
36+
return 0;
37+
}
38+
39+
public static void Default() => Console.WriteLine("Start default");
40+
public static void MakeTea() => Console.WriteLine("Tea made");
41+
}
42+
43+
public static class DrinkTeaTarget
44+
{
45+
public static void Exec() => Console.WriteLine("Ahh... lovely!");
46+
47+
}
48+
public static class GitStatus
49+
{
50+
public static void Execute()
51+
{
52+
Exec(new ExecArguments("dotnet", "xunit") { WorkingDirectory = @"src\Tests\Tests"});
53+
}
54+
}
55+
}

build/targets/targets.csproj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp2.1</TargetFramework>
6+
<LangVersion>Latest</LangVersion>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Bullseye" Version="2.3.0-alpha.1" />
11+
<PackageReference Include="Proc" Version="0.4.1" />
12+
</ItemGroup>
13+
14+
</Project>

0 commit comments

Comments
 (0)