Skip to content

Commit

Permalink
allow build version to be passed iv via command line
Browse files Browse the repository at this point in the history
  • Loading branch information
SlyckLizzie committed Jan 26, 2024
1 parent c9ddf3e commit 7a732e6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ Param(
[string]$Target = "Default",
[ValidateSet("Release", "Debug")]
[string]$Configuration = "Release",
[string]$ForceVersion = "0.0.0",
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
[string]$Verbosity = "Normal",
[string]$Verbosity = "Normal",
[switch]$WhatIf,
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
[string[]]$ScriptArgs
Expand Down Expand Up @@ -97,6 +98,7 @@ if (!(Test-Path $NugetPath)) {
$Arguments = @{
target=$Target;
configuration=$Configuration;
forceVersion=$ForceVersion;
verbosity=$Verbosity;
dryrun=$WhatIf;
}.GetEnumerator() | %{"--{0}=`"{1}`"" -f $_.key, $_.value };
Expand Down
1 change: 1 addition & 0 deletions build/Context.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class Context : FrostingContext
{
public string Target { get; set; }
public new string Configuration { get; set; }
public string ForceVersion { get; set; }
public bool FormatCode { get; set; }
public BuildVersion Version { get; set; }

Expand Down
3 changes: 2 additions & 1 deletion build/Lifetime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public override void Setup(Context context, ISetupContext setupContext)
{
context.Target = context.Argument("target", "Default");
context.Configuration = context.Argument("configuration", "Release");
context.ForceVersion = context.Argument<string>("forceVersion", "0.0.0");
context.FormatCode = context.Argument("formatCode", false);

context.Artifacts = "./packaging/";
Expand Down Expand Up @@ -46,7 +47,7 @@ public override void Setup(Context context, ISetupContext setupContext)
ToolInstaller.DotNetToolInstall(context, "coverlet.console", "1.7.2", "coverlet");

// Calculate semantic version.
context.Version = BuildVersion.Calculate(context);
context.Version = context.ForceVersion != "0.0.0" ? new BuildVersion(context.ForceVersion, null, null) : BuildVersion.Calculate(context);
context.Version.Prefix = context.Argument<string>("version", context.Version.Prefix);
context.Version.Suffix = context.Argument<string>("suffix", context.Version.Suffix);

Expand Down

0 comments on commit 7a732e6

Please sign in to comment.