diff --git a/build.ps1 b/build.ps1 index e98303f250..2c490c6251 100644 --- a/build.ps1 +++ b/build.ps1 @@ -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 @@ -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 }; diff --git a/build/Context.cs b/build/Context.cs index 6812eea00f..ad1e6b5f72 100644 --- a/build/Context.cs +++ b/build/Context.cs @@ -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; } diff --git a/build/Lifetime.cs b/build/Lifetime.cs index 21078a25f3..b46a3b431b 100644 --- a/build/Lifetime.cs +++ b/build/Lifetime.cs @@ -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("forceVersion", "0.0.0"); context.FormatCode = context.Argument("formatCode", false); context.Artifacts = "./packaging/"; @@ -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("version", context.Version.Prefix); context.Version.Suffix = context.Argument("suffix", context.Version.Suffix);