@@ -146,6 +146,11 @@ private static RootCommand BuildCommandLine()
146
146
{
147
147
Description = "The name of just one version property to print to stdout. When specified, the output is always in raw text. Useful in scripts." ,
148
148
} ;
149
+ var publicRelease = new Option < bool ? > ( "--public-release" )
150
+ {
151
+ Description = "Specifies whether this is a public release. When specified, overrides the PublicRelease environment variable. Use --public-release=true or --public-release=false to explicitly set the value." ,
152
+ Arity = ArgumentArity . ZeroOrOne ,
153
+ } ;
149
154
var commit = new Argument < string > ( "commit-ish" )
150
155
{
151
156
Description = $ "The commit/ref to get the version information for.",
@@ -158,6 +163,7 @@ private static RootCommand BuildCommandLine()
158
163
metadata ,
159
164
format ,
160
165
variable ,
166
+ publicRelease ,
161
167
commit ,
162
168
} ;
163
169
@@ -167,8 +173,9 @@ private static RootCommand BuildCommandLine()
167
173
var metadataValue = parseResult . GetValue ( metadata ) ;
168
174
var formatValue = parseResult . GetValue ( format ) ;
169
175
var variableValue = parseResult . GetValue ( variable ) ;
176
+ var publicReleaseValue = parseResult . GetValue ( publicRelease ) ;
170
177
var commitValue = parseResult . GetValue ( commit ) ;
171
- return await OnGetVersionCommand ( projectValue , metadataValue , formatValue , variableValue , commitValue ) ;
178
+ return await OnGetVersionCommand ( projectValue , metadataValue , formatValue , variableValue , publicReleaseValue , commitValue ) ;
172
179
} ) ;
173
180
}
174
181
@@ -576,7 +583,7 @@ private static async Task<int> OnInstallCommand(string path, string version, str
576
583
return ( int ) ExitCodes . OK ;
577
584
}
578
585
579
- private static Task < int > OnGetVersionCommand ( string project , string [ ] metadata , string format , string variable , string commitish )
586
+ private static Task < int > OnGetVersionCommand ( string project , string [ ] metadata , string format , string variable , bool ? publicReleaseArg , string commitish )
580
587
{
581
588
if ( string . IsNullOrEmpty ( format ) )
582
589
{
@@ -609,8 +616,12 @@ private static Task<int> OnGetVersionCommand(string project, string[] metadata,
609
616
oracle . BuildMetadata . AddRange ( metadata ) ;
610
617
}
611
618
612
- // Take the PublicRelease environment variable into account, since the build would as well.
613
- if ( ! string . IsNullOrWhiteSpace ( Environment . GetEnvironmentVariable ( "PublicRelease" ) ) && bool . TryParse ( Environment . GetEnvironmentVariable ( "PublicRelease" ) , out bool publicRelease ) )
619
+ // Set PublicRelease - prioritize command line argument over environment variable
620
+ if ( publicReleaseArg . HasValue )
621
+ {
622
+ oracle . PublicRelease = publicReleaseArg . Value ;
623
+ }
624
+ else if ( ! string . IsNullOrWhiteSpace ( Environment . GetEnvironmentVariable ( "PublicRelease" ) ) && bool . TryParse ( Environment . GetEnvironmentVariable ( "PublicRelease" ) , out bool publicRelease ) )
614
625
{
615
626
oracle . PublicRelease = publicRelease ;
616
627
}
0 commit comments