@@ -146,6 +146,11 @@ private static RootCommand BuildCommandLine()
146146 {
147147 Description = "The name of just one version property to print to stdout. When specified, the output is always in raw text. Useful in scripts." ,
148148 } ;
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+ } ;
149154 var commit = new Argument < string > ( "commit-ish" )
150155 {
151156 Description = $ "The commit/ref to get the version information for.",
@@ -158,6 +163,7 @@ private static RootCommand BuildCommandLine()
158163 metadata ,
159164 format ,
160165 variable ,
166+ publicRelease ,
161167 commit ,
162168 } ;
163169
@@ -167,8 +173,9 @@ private static RootCommand BuildCommandLine()
167173 var metadataValue = parseResult . GetValue ( metadata ) ;
168174 var formatValue = parseResult . GetValue ( format ) ;
169175 var variableValue = parseResult . GetValue ( variable ) ;
176+ var publicReleaseValue = parseResult . GetValue ( publicRelease ) ;
170177 var commitValue = parseResult . GetValue ( commit ) ;
171- return await OnGetVersionCommand ( projectValue , metadataValue , formatValue , variableValue , commitValue ) ;
178+ return await OnGetVersionCommand ( projectValue , metadataValue , formatValue , variableValue , publicReleaseValue , commitValue ) ;
172179 } ) ;
173180 }
174181
@@ -576,7 +583,7 @@ private static async Task<int> OnInstallCommand(string path, string version, str
576583 return ( int ) ExitCodes . OK ;
577584 }
578585
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 )
580587 {
581588 if ( string . IsNullOrEmpty ( format ) )
582589 {
@@ -609,8 +616,12 @@ private static Task<int> OnGetVersionCommand(string project, string[] metadata,
609616 oracle . BuildMetadata . AddRange ( metadata ) ;
610617 }
611618
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 ) )
614625 {
615626 oracle . PublicRelease = publicRelease ;
616627 }
0 commit comments