-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathICompile.cs
More file actions
61 lines (55 loc) · 2.71 KB
/
ICompile.cs
File metadata and controls
61 lines (55 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System;
using Candoumbe.Pipelines.Components.Formatting;
using Nuke.Common;
using Nuke.Common.Tooling;
using Nuke.Common.Tools.DotNet;
using Nuke.Common.Utilities.Collections;
using static Nuke.Common.Tools.DotNet.DotNetTasks;
using static Serilog.Log;
namespace Candoumbe.Pipelines.Components;
/// <summary>
/// Marks a pipeline that can compile a <see cref="IHaveSolution.Solution"/>
/// </summary>
public interface ICompile : IHaveSolution, IHaveConfiguration
{
/// <summary>
/// Compiles the specified
/// </summary>
public Target Compile => _ => _
.Description($"Compiles {Solution}")
.TryDependsOn<IRestore>()
.TryDependsOn<IFormat>()
.Executes(() =>
{
Information("Compiling {Solution}", Solution);
ReportSummary(_ => _.WhenNotNull(this.As<IHaveGitVersion>(),
(_, version) => _.AddPair("Version", version.GitVersion.FullSemVer)));
DotNetBuild(s => s
.Apply(CompileSettingsBase)
.Apply(CompileSettings)
);
});
/// <summary>
/// Default compilation settings
/// </summary>
public sealed Configure<DotNetBuildSettings> CompileSettingsBase => _ => _
.WhenNotNull(this.As<IRestore>(),
(_, restore) => _.SetNoRestore(SucceededTargets.Contains(restore.Restore) || SkippedTargets.Contains(restore.Restore)))
.SetProjectFile(Solution)
.SetConfiguration(Configuration)
.SetContinuousIntegrationBuild(IsServerBuild)
.SetProcessAdditionalArguments("--tl")
.WhenNotNull(this.As<IHaveGitVersion>(),
(settings, gitVersion) => settings.SetAssemblyVersion(gitVersion.GitVersion.AssemblySemVer)
.SetFileVersion(gitVersion.GitVersion.AssemblySemFileVer)
.SetInformationalVersion(gitVersion.GitVersion.InformationalVersion)
.SetVersion(gitVersion.GitVersion.NuGetVersion)
.SetSymbolPackageFormat(DotNetSymbolPackageFormat.snupkg)
.WhenNotNull(this as IHaveChangeLog,
(setting, changelog) => setting.SetPackageReleaseNotes(changelog.ReleaseNotes))
);
/// <summary>
/// Configures the compilation settings
/// </summary>
public Configure<DotNetBuildSettings> CompileSettings => _ => _;
}