Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] Allow build version to be passed in to build.ps1 via command line #2864

Merged
merged 2 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading