From 6fb3bf6a6b9ba32efad8ab6569a2c54d29c6f53d Mon Sep 17 00:00:00 2001 From: "Wenzel, Toni" Date: Tue, 1 Oct 2024 16:45:59 +0200 Subject: [PATCH] Update publish task --- build.cake | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/build.cake b/build.cake index 932ea4f..12007ff 100644 --- a/build.cake +++ b/build.cake @@ -13,8 +13,9 @@ var nugetApiKey = Argument("nugetApiKey", EnvironmentVariable("NUGET_API_KEY") ? ///////////////////////////////////////////////////////////////////// var solution = "./CHG.Extensions.Security.sln"; var project = "./src/CHG.Extensions.Security.Txt.csproj"; -var outputDir = MakeAbsolute(Directory("./buildArtifacts/")); -var outputDirNuget = outputDir.Combine("NuGet"); +var outputDir = Directory("./buildArtifacts/").Path.MakeAbsolute(Context.Environment); +var outputDirPublished = outputDir.Combine("Published"); +var packageOutputDir = outputDirPublished.Combine("Package"); var sonarProjectKey = "CHG-MERIDIAN_CHG.Extensions.Security.Txt"; var sonarUrl = "https://sonarcloud.io"; var sonarOrganization = "chg-meridian"; @@ -40,6 +41,7 @@ var runSonar = !string.IsNullOrWhiteSpace(sonarLogin); Setup(context => { + Information($"Package output directory: {packageOutputDir.FullPath}"); Information($"Local build: {isLocalBuild}"); Information($"Master branch: {isMasterBranch}"); Information($"Pull request: {isPullRequest}"); @@ -59,6 +61,7 @@ Task("Clean") Force = true }); CreateDirectory(outputDir); + CreateDirectory(outputDirPublished); }); GitVersion versionInfo = null; @@ -102,7 +105,7 @@ Task("Build") Version = versionInfo.AssemblySemVer, InformationalVersion = versionInfo.InformationalVersion, PackageVersion = versionInfo.SemVer - }.WithProperty("PackageOutputPath", outputDirNuget.FullPath); + }.WithProperty("PackageOutputPath", packageOutputDir.FullPath); var settings = new DotNetBuildSettings { @@ -167,8 +170,16 @@ Task("Publish") .Does(() => { - // Get the paths to the packages. - var packages = GetFiles(outputDirNuget + "*.nupkg"); + Information($"Upload packages from {packageOutputDir.FullPath}"); + + // Get the paths to the packages ordered by the file names in order to get the nupkg first. + var packages = GetFiles(packageOutputDir.CombineWithFilePath("*.*nupkg").ToString()).OrderBy(x => x.FullPath).ToArray(); + + if (packages.Length == 0) + { + Error("No packages found to upload"); + return; + } // Push the package and symbols NuGetPush(packages, new NuGetPushSettings