Skip to content

Commit

Permalink
Merge pull request #49 from twenzel/feature/UpdateProject
Browse files Browse the repository at this point in the history
Update publish task
  • Loading branch information
twenzel authored Oct 1, 2024
2 parents adbcf43 + 6fb3bf6 commit 1dba73e
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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}");
Expand All @@ -59,6 +61,7 @@ Task("Clean")
Force = true
});
CreateDirectory(outputDir);
CreateDirectory(outputDirPublished);
});

GitVersion versionInfo = null;
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1dba73e

Please sign in to comment.