Skip to content

Commit e8ecd9e

Browse files
committed
Add ability to publish individual project
1 parent c5caf0e commit e8ecd9e

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

build/Build.cs

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ partial class Build : NukeBuild
6666
[Parameter($"The name of the current git branch. OctoVersion will use this to calculate the version number. This can be set via the environment variable {CiBranchNameEnvVariable}.", Name = CiBranchNameEnvVariable)]
6767
string? BranchName { get; set; }
6868

69+
[Parameter] readonly string? ProjectToBuild;
70+
6971
//this is instantiated in the constructor
7072
readonly Lazy<OctoVersionInfo?> OctoVersionInfo;
7173

@@ -134,7 +136,8 @@ public Build()
134136

135137
Target Clean =>
136138
d =>
137-
d.Executes(() =>
139+
d.DependsOn(CheckForbiddenWords)
140+
.Executes(() =>
138141
{
139142
SourceDirectory.GlobDirectories("**/bin", "**/obj", "**/TestResults").ForEach(d => d.DeleteDirectory());
140143
ArtifactsDirectory.CreateOrCleanDirectory();
@@ -148,7 +151,7 @@ public Build()
148151
{
149152
//Do one big, default restore
150153
DotNetRestore(s => s.SetProjectFile(Solution));
151-
154+
152155
var allRuntimeIds = ListAllRuntimeIdentifiersInSolution();
153156
//we restore for all individual runtimes
154157
foreach (var runtimeId in allRuntimeIds)
@@ -177,6 +180,12 @@ public Build()
177180
.Where(project => allProjectNames.Contains(project.Name))
178181
.ToList();
179182

183+
//if this is not
184+
if (!string.IsNullOrEmpty(ProjectToBuild))
185+
{
186+
calamariProjects = calamariProjects.Where(p => p.Name == ProjectToBuild || p.Name == $"{ProjectToBuild}.Tests").ToList();
187+
}
188+
180189
CalamariProjects = calamariProjects;
181190

182191
//all packages are cross-platform
@@ -226,9 +235,7 @@ await Task.Run(() => DotNetBuild(s =>
226235
.SetConfiguration(Configuration)
227236
.SetFramework(calamariPackageMetadata.Framework)
228237
.SetRuntime(calamariPackageMetadata.Architecture)
229-
.EnableSelfContained()
230-
.EnableNoRestore() //we _should_ have restored everything earlier
231-
.SetVerbosity(projectName == "Calamari.Tests" ? DotNetVerbosity.detailed : DotNetVerbosity.minimal)));
238+
.EnableSelfContained()));
232239
}
233240
finally
234241
{
@@ -318,6 +325,8 @@ async Task CompressCalamariProject(Project project)
318325

319326
Target PublishAzureWebAppNetCoreShim =>
320327
_ => _.DependsOn(RestoreSolution)
328+
//we only build the net core shim when there is the AzureWebApp project is being built
329+
.OnlyWhenDynamic(() => CalamariProjects.Any(p => p.Name == "Calamari.AzureWebApp"))
321330
.Executes(() =>
322331
{
323332
if (!OperatingSystem.IsWindows())
@@ -349,11 +358,11 @@ async Task CompressCalamariProject(Project project)
349358

350359
outputPath.CompressTo(archivePath);
351360
});
352-
361+
362+
353363
Target PackageConsolidatedCalamariZip =>
354364
d =>
355-
d.DependsOn(PublishCalamariProjects)
356-
.Executes(() =>
365+
d.Executes(() =>
357366
{
358367
var artifacts = Directory.GetFiles(ArtifactsDirectory, "*.nupkg")
359368
.Where(a => !NuGetPackagesToExcludeFromConsolidation.Any(a.Contains));
@@ -467,13 +476,18 @@ async Task CompressCalamariProject(Project project)
467476
Target SetTeamCityVersion => d => d.Executes(() => TeamCity.Instance?.SetBuildNumber(NugetVersion.Value));
468477

469478
Target BuildLocal => d =>
470-
d.DependsOn(PackCalamariConsolidatedNugetPackage)
479+
d.DependsOn(PublishCalamariProjects)
480+
.DependsOn(PackCalamariConsolidatedNugetPackage)
471481
.DependsOn(UpdateCalamariVersionOnOctopusServer);
472482

473483
Target BuildCi => d =>
474484
d.DependsOn(SetTeamCityVersion)
485+
.DependsOn(PublishCalamariProjects)
475486
.DependsOn(PackCalamariConsolidatedNugetPackage);
476487

488+
Target BuildAndPublishProject => d => d.OnlyWhenDynamic(() => !string.IsNullOrEmpty(ProjectToBuild)).DependsOn(PublishCalamariProjects);
489+
490+
477491
public static int Main() => Execute<Build>(x => IsServerBuild ? x.BuildCi : x.BuildLocal);
478492

479493
void SignDirectory(string directory)

0 commit comments

Comments
 (0)