Skip to content

Commit 76c0b45

Browse files
authored
Optimized deterministic builds (#1428)
1 parent 2ffcc2c commit 76c0b45

3 files changed

Lines changed: 19 additions & 23 deletions

File tree

.nuke/build.schema.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,21 @@
88
"properties": {
99
"CI": {
1010
"type": "boolean",
11-
"description": "Sets the continuous integration build flag"
11+
"description": "Forces the continuous integration build flag"
1212
},
1313
"Configuration": {
1414
"type": "string",
1515
"description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)",
1616
"enum": [
1717
"Debug",
18-
"Release"
18+
"Release",
19+
"Verify"
1920
]
2021
},
2122
"Continue": {
2223
"type": "boolean",
2324
"description": "Indicates to continue a previously failed build attempt"
2425
},
25-
"Deterministic": {
26-
"type": "boolean",
27-
"description": "Makes the build deterministic when packaging assemblies"
28-
},
2926
"github-token": {
3027
"type": "string",
3128
"description": "GitHub auth token",

build/Build.cs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,32 +50,26 @@ partial class Build : NukeBuild
5050
[Solution] readonly Solution Solution;
5151
[GitRepository] readonly GitRepository GitRepository;
5252
[GitVersion] readonly GitVersion GitVersion;
53-
54-
[Parameter("Makes the build deterministic when packaging assemblies")] readonly bool Deterministic;
55-
[Parameter("Sets the continuous integration build flag")] readonly bool CI;
56-
57-
[Secret]
58-
[Parameter("NuGet API Key (secret)", Name = Secrets.NuGetApiKey)]
59-
readonly string NuGetApiKey;
60-
61-
readonly string NuGetSource = "https://api.nuget.org/v3/index.json";
62-
6353
[CI] readonly GitHubActions GitHubActions;
6454

6555
[Parameter("GitHub auth token", Name = "github-token"), Secret] readonly string GitHubToken;
56+
[Parameter("Forces the continuous integration build flag")] readonly bool CI;
6657

67-
IEnumerable<Project> Excluded => new []
58+
[Secret] [Parameter("NuGet API Key (secret)", Name = Secrets.NuGetApiKey)] readonly string NuGetApiKey;
59+
readonly string NuGetSource = "https://api.nuget.org/v3/index.json";
60+
61+
IEnumerable<Project> Excluded => new[]
6862
{
6963
Solution.GetProject("_build"),
7064
Solution.GetProject("TestTypeFoundation")
7165
};
66+
7267
IEnumerable<Project> TestProjects => Solution.GetProjects("*Test");
7368
IEnumerable<Project> Libraries => Solution.Projects.Except(TestProjects).Except(Excluded);
7469
IEnumerable<Project> CSharpLibraries => Libraries.Where(x => x.Is(ProjectType.CSharpProject));
7570
IEnumerable<Project> FSharpLibraries => Libraries.Where(x => x.Path.ToString().EndsWith(".fsproj"));
7671
IEnumerable<AbsolutePath> Packages => PackagesDirectory.GlobFiles("*.nupkg");
7772

78-
bool IsDeterministic => IsServerBuild || Deterministic;
7973
bool IsContinuousIntegration => IsServerBuild || CI;
8074

8175
AbsolutePath SourceDirectory => RootDirectory / "src";
@@ -111,7 +105,7 @@ partial class Build : NukeBuild
111105
{
112106
DotNetBuild(s => s
113107
.SetProjectFile(Solution)
114-
.SetConfiguration("Verify")
108+
.SetConfiguration(Configuration.Verify)
115109
.SetNoRestore(FinishedTargets.Contains(Restore))
116110
.SetContinuousIntegrationBuild(IsContinuousIntegration)
117111
.SetProcessArgumentConfigurator(a => a
@@ -125,12 +119,14 @@ partial class Build : NukeBuild
125119
DotNetBuild(s => s
126120
.SetProjectFile(Solution)
127121
.SetConfiguration(Configuration)
122+
.SetDeterministic(IsContinuousIntegration)
123+
.SetContinuousIntegrationBuild(IsContinuousIntegration)
124+
.SetSymbolPackageFormat(DotNetSymbolPackageFormat.snupkg)
128125
.SetVersion(GitVersion.NuGetVersionV2)
129126
.SetAssemblyVersion(GitVersion.AssemblySemVer)
130127
.SetFileVersion(GitVersion.AssemblySemFileVer)
131128
.SetInformationalVersion(GitVersion.InformationalVersion)
132129
.SetNoRestore(FinishedTargets.Contains(Restore))
133-
.SetContinuousIntegrationBuild(IsContinuousIntegration)
134130
.SetProcessArgumentConfigurator(a => a
135131
.Add("/p:CheckEolTargetFramework=false")));
136132
});
@@ -181,15 +177,17 @@ partial class Build : NukeBuild
181177
.Executes(() =>
182178
{
183179
DotNetPack(s => s
180+
.SetConfiguration(Configuration)
181+
.SetNoBuild(FinishedTargets.Contains(Compile))
184182
.SetOutputDirectory(PackagesDirectory)
185183
.SetSymbolPackageFormat(DotNetSymbolPackageFormat.snupkg)
186184
.EnableIncludeSymbols()
185+
.SetDeterministic(IsContinuousIntegration)
186+
.SetContinuousIntegrationBuild(IsContinuousIntegration)
187187
.SetVersion(GitVersion.NuGetVersionV2)
188188
.SetAssemblyVersion(GitVersion.AssemblySemVer)
189189
.SetFileVersion(GitVersion.AssemblySemFileVer)
190190
.SetInformationalVersion(GitVersion.InformationalVersion)
191-
.SetDeterministic(IsDeterministic)
192-
.SetContinuousIntegrationBuild(IsContinuousIntegration)
193191
.SetProcessArgumentConfigurator(a => a
194192
.Add("/p:CheckEolTargetFramework=false"))
195193
.CombineWith(CSharpLibraries, (s, p) => s.SetProject(p)));
@@ -199,11 +197,11 @@ partial class Build : NukeBuild
199197
.SetOutputDirectory(PackagesDirectory)
200198
.SetSymbolPackageFormat(DotNetSymbolPackageFormat.snupkg)
201199
.EnableIncludeSymbols()
200+
.SetContinuousIntegrationBuild(IsContinuousIntegration)
202201
.SetVersion(GitVersion.NuGetVersionV2)
203202
.SetAssemblyVersion(GitVersion.AssemblySemVer)
204203
.SetFileVersion(GitVersion.AssemblySemFileVer)
205204
.SetInformationalVersion(GitVersion.InformationalVersion)
206-
.SetContinuousIntegrationBuild(IsContinuousIntegration)
207205
.SetProcessArgumentConfigurator(a => a
208206
.Add("/p:CheckEolTargetFramework=false"))
209207
.CombineWith(FSharpLibraries, (s, p) => s.SetProject(p)));

build/Configuration.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ public class Configuration : Enumeration
66
{
77
public static Configuration Debug = new() { Value = nameof(Debug) };
88
public static Configuration Release = new() { Value = nameof(Release) };
9+
public static Configuration Verify = new() { Value = nameof(Verify) };
910

1011
public static implicit operator string(Configuration configuration)
1112
{

0 commit comments

Comments
 (0)