@@ -143,7 +143,7 @@ public IEnumerable<string> BuildMetadataWithCommitId
143143 {
144144 if ( ! string . IsNullOrEmpty ( this . GitCommitId ) )
145145 {
146- yield return $ "g { this . GitCommitId . Substring ( 0 , 10 ) } " ;
146+ yield return this . GitCommitId . Substring ( 0 , 10 ) ;
147147 }
148148
149149 foreach ( string identifier in this . BuildMetadata )
@@ -335,22 +335,22 @@ public IDictionary<string, string> CloudBuildVersionVars
335335 /// <summary>
336336 /// Gets the version to use for NuGet packages.
337337 /// </summary>
338- public string NuGetPackageVersion => this . VersionOptions ? . NuGetPackageVersionOrDefault . SemVerOrDefault == 1 ? this . SemVer1 : this . SemVer2 ;
338+ public string NuGetPackageVersion => this . VersionOptions ? . NuGetPackageVersionOrDefault . SemVerOrDefault == 1 ? this . NuGetSemVer1 : this . SemVer2 ;
339339
340340 /// <summary>
341341 /// Gets the version to use for NPM packages.
342342 /// </summary>
343343 public string NpmPackageVersion => this . SemVer2 ;
344344
345345 /// <summary>
346- /// Gets a SemVer 1.0 compliant string that represents this version, including the -gCOMMITID suffix
346+ /// Gets a SemVer 1.0 compliant string that represents this version, including the -COMMITID suffix
347347 /// when <see cref="PublicRelease"/> is <c>false</c>.
348348 /// </summary>
349349 public string SemVer1 =>
350350 $ "{ this . Version . ToStringSafe ( 3 ) } { this . PrereleaseVersionSemVer1 } { this . SemVer1BuildMetadata } ";
351351
352352 /// <summary>
353- /// Gets a SemVer 2.0 compliant string that represents this version, including a +gCOMMITID suffix
353+ /// Gets a SemVer 2.0 compliant string that represents this version, including a +COMMITID suffix
354354 /// when <see cref="PublicRelease"/> is <c>false</c>.
355355 /// </summary>
356356 public string SemVer2 =>
@@ -361,9 +361,31 @@ public IDictionary<string, string> CloudBuildVersionVars
361361 /// </summary>
362362 public int SemVer1NumericIdentifierPadding => this . VersionOptions ? . SemVer1NumericIdentifierPaddingOrDefault ?? 4 ;
363363
364- private string SemVer1BuildMetadata =>
364+ /// <summary>
365+ /// Gets the build metadata, compliant to the NuGet-compatible subset of SemVer 1.0.
366+ /// </summary>
367+ /// <remarks>
368+ /// When adding the git commit ID in a -prerelease tag, prefix a `g` because
369+ /// older NuGet clients (the ones that support only a subset of semver 1.0)
370+ /// cannot handle prerelease tags that begin with a number (which a git commit ID might).
371+ /// See <see href="https://github.com/AArnott/Nerdbank.GitVersioning/issues/260#issuecomment-445511898">this discussion</see>.
372+ /// </remarks>
373+ private string NuGetSemVer1BuildMetadata =>
365374 this . PublicRelease ? string . Empty : $ "-g{ this . GitCommitIdShort } ";
366375
376+ /// <summary>
377+ /// Gets the build metadata, compliant to SemVer 1.0.
378+ /// </summary>
379+ private string SemVer1BuildMetadata =>
380+ this . PublicRelease ? string . Empty : this . GitCommitIdShort ;
381+
382+ /// <summary>
383+ /// Gets a SemVer 1.0 compliant string that represents this version, including the -gCOMMITID suffix
384+ /// when <see cref="PublicRelease"/> is <c>false</c>.
385+ /// </summary>
386+ private string NuGetSemVer1 =>
387+ $ "{ this . Version . ToStringSafe ( 3 ) } { this . PrereleaseVersionSemVer1 } { this . NuGetSemVer1BuildMetadata } ";
388+
367389 /// <summary>
368390 /// Gets the build metadata that is appropriate for SemVer2 use.
369391 /// </summary>
@@ -377,7 +399,7 @@ public IDictionary<string, string> CloudBuildVersionVars
377399
378400 private string PrereleaseVersionSemVer1 => MakePrereleaseSemVer1Compliant ( this . PrereleaseVersion , this . SemVer1NumericIdentifierPadding ) ;
379401
380- private string GitCommitIdShortForNonPublicPrereleaseTag => ( string . IsNullOrEmpty ( this . PrereleaseVersion ) ? "-" : "." ) + $ "g { this . GitCommitIdShort } " ;
402+ private string GitCommitIdShortForNonPublicPrereleaseTag => ( string . IsNullOrEmpty ( this . PrereleaseVersion ) ? "-" : "." ) + this . GitCommitIdShort ;
381403
382404 private VersionOptions . CloudBuildNumberOptions CloudBuildNumberOptions { get ; }
383405
0 commit comments