-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
60716be
commit 4c5a7b3
Showing
5 changed files
with
29 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,12 +9,15 @@ namespace build | |
{ | ||
class Program | ||
{ | ||
private const bool RequireTests = true; | ||
private static class Targets | ||
{ | ||
public const string Build = "build"; | ||
public const string Test = "test"; | ||
public const string Pack = "pack"; | ||
} | ||
|
||
static string BinaryToSign = "IdentityModel.OidcClient.dll"; | ||
|
||
private const string ArtifactsDir = "artifacts"; | ||
private const string Build = "build"; | ||
private const string Test = "test"; | ||
private const string Pack = "pack"; | ||
|
||
static void Main(string[] args) | ||
{ | ||
|
@@ -25,52 +28,35 @@ static void Main(string[] args) | |
|
||
app.OnExecute(() => | ||
{ | ||
Target(Build, () => | ||
Target(Targets.Build, () => | ||
{ | ||
var solution = Directory.GetFiles(".", "*.sln", SearchOption.TopDirectoryOnly).First(); | ||
Run("dotnet", $"build {solution} -c Release"); | ||
Run("dotnet", $"build -c Release"); | ||
if (sign.HasValue()) | ||
{ | ||
Sign("IdentityModel.OidcClient.dll", "./src/bin/release"); | ||
Sign(BinaryToSign, "./src/bin/release"); | ||
} | ||
}); | ||
Target(Test, DependsOn(Build), () => | ||
Target(Targets.Test, DependsOn(Targets.Build), () => | ||
{ | ||
try | ||
{ | ||
var tests = Directory.GetFiles("./test", "*.csproj", SearchOption.AllDirectories); | ||
foreach (var test in tests) | ||
{ | ||
Run("dotnet", $"test {test} -c Release --no-build"); | ||
} | ||
} | ||
catch (System.IO.DirectoryNotFoundException ex) | ||
{ | ||
if (RequireTests) | ||
{ | ||
throw new Exception($"No tests found: {ex.Message}"); | ||
}; | ||
} | ||
Run("dotnet", $"test -c Release --no-build"); | ||
}); | ||
Target(Pack, DependsOn(Build), () => | ||
Target(Targets.Pack, DependsOn(Targets.Test), () => | ||
{ | ||
var project = Directory.GetFiles("./src", "*.csproj", SearchOption.TopDirectoryOnly).First(); | ||
Run("dotnet", $"pack {project} -c Release -o ./{ArtifactsDir} --no-build"); | ||
Run("dotnet", $"pack {project} -c Release -o ./artifacts --no-build"); | ||
if (sign.HasValue()) | ||
{ | ||
Sign("*.nupkg", $"./{ArtifactsDir}"); | ||
Sign("*.nupkg", $"./artifacts"); | ||
} | ||
}); | ||
Target("default", DependsOn(Test, Pack)); | ||
Target("default", DependsOn(Targets.Test, Targets.Pack)); | ||
RunTargetsAndExit(app.RemainingArguments); | ||
}); | ||
|
||
|
@@ -97,15 +83,15 @@ private static void Sign(string extension, string directory) | |
foreach (var file in files) | ||
{ | ||
Console.WriteLine(" Signing " + file); | ||
Run("./tools/signclient", $"sign -c {signClientConfig} -i {file} -r [email protected] -s \"{signClientSecret}\" -n 'IdentityServer4'", noEcho: true); | ||
Run("dotnet", $"SignClient sign -c {signClientConfig} -i {file} -r [email protected] -s \"{signClientSecret}\" -n 'IdentityServer4'", noEcho: true); | ||
} | ||
} | ||
|
||
private static void CleanArtifacts() | ||
{ | ||
Directory.CreateDirectory($"./{ArtifactsDir}"); | ||
Directory.CreateDirectory($"./artifacts"); | ||
|
||
foreach (var file in Directory.GetFiles($"./{ArtifactsDir}")) | ||
foreach (var file in Directory.GetFiles($"./artifacts")) | ||
{ | ||
File.Delete(file); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters