Skip to content

Commit b3d9340

Browse files
updated build
1 parent 3fdf57f commit b3d9340

File tree

7 files changed

+46
-41
lines changed

7 files changed

+46
-41
lines changed

.config/dotnet-tools.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"signclient": {
6+
"version": "1.2.17",
7+
"commands": [
8+
"SignClient"
9+
]
10+
}
11+
}
12+
}

build.cmd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
@echo off
2-
dotnet tool install --tool-path tools SignClient
2+
dotnet tool restore
3+
34
dotnet run --project build -- %*

build.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
dotnet tool install --tool-path tools SignClient
2-
31
$ErrorActionPreference = "Stop";
2+
dotnet tool restore
3+
44
dotnet run --project build -- $args

build.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
3+
dotnet tool restore
4+
35
dotnet run --project build -- "$@"

build/Program.cs

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ namespace build
99
{
1010
class Program
1111
{
12-
private const bool RequireTests = true;
12+
private static class Targets
13+
{
14+
public const string Build = "build";
15+
public const string Test = "test";
16+
public const string Pack = "pack";
17+
}
18+
19+
static string BinaryToSign = "IdentityServer4.AccessTokenValidation.dll";
1320

14-
private const string ArtifactsDir = "artifacts";
15-
private const string Build = "build";
16-
private const string Test = "test";
17-
private const string Pack = "pack";
1821

1922
static void Main(string[] args)
2023
{
@@ -25,52 +28,35 @@ static void Main(string[] args)
2528

2629
app.OnExecute(() =>
2730
{
28-
Target(Build, () =>
31+
Target(Targets.Build, () =>
2932
{
30-
var solution = Directory.GetFiles(".", "*.sln", SearchOption.TopDirectoryOnly).First();
31-
32-
Run("dotnet", $"build {solution} -c Release");
33+
Run("dotnet", $"build -c Release");
3334

3435
if (sign.HasValue())
3536
{
36-
Sign("IdentityServer4.AccessTokenValidation.dll", "./src/bin/release");
37+
Sign(BinaryToSign, "./src/bin/release");
3738
}
3839
});
3940

40-
Target(Test, DependsOn(Build), () =>
41+
Target(Targets.Test, DependsOn(Targets.Build), () =>
4142
{
42-
try
43-
{
44-
var tests = Directory.GetFiles("./test", "*.csproj", SearchOption.AllDirectories);
45-
46-
foreach (var test in tests)
47-
{
48-
Run("dotnet", $"test {test} -c Release --no-build");
49-
}
50-
}
51-
catch (System.IO.DirectoryNotFoundException ex)
52-
{
53-
if (RequireTests)
54-
{
55-
throw new Exception($"No tests found: {ex.Message}");
56-
};
57-
}
43+
Run("dotnet", $"test -c Release --no-build");
5844
});
5945

60-
Target(Pack, DependsOn(Build), () =>
46+
Target(Targets.Pack, DependsOn(Targets.Test), () =>
6147
{
6248
var project = Directory.GetFiles("./src", "*.csproj", SearchOption.TopDirectoryOnly).First();
6349

64-
Run("dotnet", $"pack {project} -c Release -o ./{ArtifactsDir} --no-build");
50+
Run("dotnet", $"pack {project} -c Release -o ./artifacts --no-build");
6551

6652
if (sign.HasValue())
6753
{
68-
Sign("*.nupkg", $"./{ArtifactsDir}");
54+
Sign("*.nupkg", $"./artifacts");
6955
}
7056
});
7157

7258

73-
Target("default", DependsOn(Test, Pack));
59+
Target("default", DependsOn(Targets.Test, Targets.Pack));
7460
RunTargetsAndExit(app.RemainingArguments);
7561
});
7662

@@ -93,19 +79,23 @@ private static void Sign(string extension, string directory)
9379
}
9480

9581
var files = Directory.GetFiles(directory, extension, SearchOption.AllDirectories);
82+
if (files.Count() == 0)
83+
{
84+
throw new Exception($"File to sign not found: {extension}");
85+
}
9686

9787
foreach (var file in files)
9888
{
9989
Console.WriteLine(" Signing " + file);
100-
Run("./tools/signclient", $"sign -c {signClientConfig} -i {file} -r [email protected] -s \"{signClientSecret}\" -n 'IdentityServer4'", noEcho: true);
90+
Run("dotnet", $"SignClient sign -c {signClientConfig} -i {file} -r [email protected] -s \"{signClientSecret}\" -n 'IdentityServer4'", noEcho: true);
10191
}
10292
}
10393

10494
private static void CleanArtifacts()
10595
{
106-
Directory.CreateDirectory($"./{ArtifactsDir}");
96+
Directory.CreateDirectory($"./artifacts");
10797

108-
foreach (var file in Directory.GetFiles($"./{ArtifactsDir}"))
98+
foreach (var file in Directory.GetFiles($"./artifacts"))
10999
{
110100
File.Delete(file);
111101
}

build/build.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Bullseye" Version="3.0.0-rc.1" />
10-
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="2.4.1" />
11-
<PackageReference Include="SimpleExec" Version="6.0.0" />
9+
<PackageReference Include="Bullseye" Version="3.0.0" />
10+
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="2.4.4" />
11+
<PackageReference Include="SimpleExec" Version="6.1.0" />
1212
</ItemGroup>
1313

1414
</Project>

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"sdk": {
3-
"version": "3.0.100"
3+
"version": "3.1.100"
44
}
55
}

0 commit comments

Comments
 (0)