Skip to content

Commit da5255e

Browse files
committed
Fix pack in CI.
1 parent c1359cb commit da5255e

File tree

2 files changed

+47
-23
lines changed

2 files changed

+47
-23
lines changed

build/BenchmarkDotNet.Build/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public HelpInfo GetHelp()
221221
[IsDependentOn(typeof(BuildAnalyzersTask))]
222222
public class PackTask : FrostingTask<BuildContext>, IHelpProvider
223223
{
224-
private const string Name = "pack";
224+
public const string Name = "pack";
225225
public override void Run(BuildContext context) => context.BuildRunner.Pack();
226226

227227
public HelpInfo GetHelp()
@@ -340,7 +340,7 @@ public override void Run(BuildContext context)
340340
[IsDependentOn(typeof(DocsBuildTask))]
341341
public class ReleaseTask : FrostingTask<BuildContext>, IHelpProvider
342342
{
343-
private const string Name = "release";
343+
public const string Name = "release";
344344
public override void Run(BuildContext context) => context.ReleaseRunner.Run();
345345

346346
public HelpInfo GetHelp() => new()

build/BenchmarkDotNet.Build/Runners/BuildRunner.cs

Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Cake.Common.Tools.DotNet.Workload.Install;
99
using Cake.Core;
1010
using Cake.Core.IO;
11+
using System;
1112
using System.IO;
1213
using System.Linq;
1314

@@ -16,54 +17,73 @@ namespace BenchmarkDotNet.Build.Runners;
1617
public class BuildRunner
1718
{
1819
private readonly BuildContext context;
20+
private readonly bool isFullPack;
1921

2022
public BuildRunner(BuildContext context)
2123
{
2224
this.context = context;
25+
isFullPack = context.Arguments.GetArgument("target") is PackTask.Name or ReleaseTask.Name;
26+
}
27+
28+
private void MaybeAppendArgument(DotNetSettings settings)
29+
{
30+
if (isFullPack)
31+
{
32+
settings.ArgumentCustomization = args => args.Append("-p:IsFullPack=true");
33+
}
2334
}
2435

2536
public void PackWeaver()
2637
{
2738
var weaverPath = context.AllPackableSrcProjects.Single(p => p.GetFilename() == "BenchmarkDotNet.Weaver.csproj");
2839
var outputPackageDir = weaverPath.GetDirectory().Combine("packages");
2940

30-
// Delete old package.
31-
foreach (var file in Directory.EnumerateFiles(outputPackageDir.FullPath))
41+
if (!isFullPack)
3242
{
33-
File.Delete(file);
43+
// Delete old package.
44+
foreach (var file in Directory.EnumerateFiles(outputPackageDir.FullPath))
45+
{
46+
File.Delete(file);
47+
}
3448
}
3549

36-
context.DotNetRestore(weaverPath.GetDirectory().FullPath,
37-
new DotNetRestoreSettings
38-
{
39-
MSBuildSettings = context.MsBuildSettingsRestore
40-
});
50+
var restoreSettings = new DotNetRestoreSettings
51+
{
52+
MSBuildSettings = context.MsBuildSettingsRestore,
53+
};
54+
MaybeAppendArgument(restoreSettings);
55+
context.DotNetRestore(weaverPath.GetDirectory().FullPath, restoreSettings);
4156

4257
context.Information("BuildSystemProvider: " + context.BuildSystem().Provider);
43-
context.DotNetBuild(weaverPath.FullPath, new DotNetBuildSettings
58+
var buildSettings = new DotNetBuildSettings
4459
{
4560
NoRestore = true,
4661
DiagnosticOutput = true,
4762
MSBuildSettings = context.MsBuildSettingsBuild,
4863
Configuration = context.BuildConfiguration,
4964
Verbosity = context.BuildVerbosity
50-
});
65+
};
66+
MaybeAppendArgument(buildSettings);
67+
context.DotNetBuild(weaverPath.FullPath, buildSettings);
5168

52-
context.DotNetPack(weaverPath.FullPath, new DotNetPackSettings
69+
var packSettings = new DotNetPackSettings
5370
{
5471
OutputDirectory = outputPackageDir,
5572
MSBuildSettings = context.MsBuildSettingsPack,
5673
Configuration = context.BuildConfiguration
57-
});
74+
};
75+
MaybeAppendArgument(packSettings);
76+
context.DotNetPack(weaverPath.FullPath, packSettings);
5877
}
5978

6079
public void Restore()
6180
{
62-
context.DotNetRestore(context.SolutionFile.FullPath,
63-
new DotNetRestoreSettings
64-
{
65-
MSBuildSettings = context.MsBuildSettingsRestore
66-
});
81+
var restoreSettings = new DotNetRestoreSettings
82+
{
83+
MSBuildSettings = context.MsBuildSettingsRestore,
84+
};
85+
MaybeAppendArgument(restoreSettings);
86+
context.DotNetRestore(context.SolutionFile.FullPath, restoreSettings);
6787
}
6888

6989
public void InstallWorkload(string workloadId)
@@ -79,26 +99,30 @@ public void InstallWorkload(string workloadId)
7999
public void Build()
80100
{
81101
context.Information("BuildSystemProvider: " + context.BuildSystem().Provider);
82-
context.DotNetBuild(context.SolutionFile.FullPath, new DotNetBuildSettings
102+
var buildSettings = new DotNetBuildSettings
83103
{
84104
NoRestore = true,
85105
DiagnosticOutput = true,
86106
MSBuildSettings = context.MsBuildSettingsBuild,
87107
Configuration = context.BuildConfiguration,
88108
Verbosity = context.BuildVerbosity
89-
});
109+
};
110+
MaybeAppendArgument(buildSettings);
111+
context.DotNetBuild(context.SolutionFile.FullPath, buildSettings);
90112
}
91113

92114
public void BuildProjectSilent(FilePath projectFile)
93115
{
94-
context.DotNetBuild(projectFile.FullPath, new DotNetBuildSettings
116+
var buildSettings = new DotNetBuildSettings
95117
{
96118
NoRestore = false,
97119
DiagnosticOutput = false,
98120
MSBuildSettings = context.MsBuildSettingsBuild,
99121
Configuration = context.BuildConfiguration,
100122
Verbosity = DotNetVerbosity.Quiet
101-
});
123+
};
124+
MaybeAppendArgument(buildSettings);
125+
context.DotNetBuild(projectFile.FullPath, buildSettings);
102126
}
103127

104128
public void BuildAnalyzers()

0 commit comments

Comments
 (0)