@@ -945,16 +945,25 @@ private void AssertStandardProperties(VersionOptions versionOptions, BuildResult
945945 Assert . Equal ( versionOptions . Version . Prerelease , buildResult . PrereleaseVersion ) ;
946946 Assert . Equal ( expectedBuildMetadata , buildResult . SemVerBuildSuffix ) ;
947947
948- // NuGet is now SemVer 2.0 and will pass additional build metadata if provided
949- bool semVer2 = versionOptions ? . NuGetPackageVersionOrDefault . SemVer == 2 ;
950- string semVer1CommitPrefix = semVer2 ? string . Empty : "g" ;
951- string pkgVersionSuffix = buildResult . PublicRelease ? string . Empty : $ "-{ semVer1CommitPrefix } { commitIdShort } ";
952- if ( semVer2 )
948+ string GetPkgVersionSuffix ( bool useSemVer2 )
953949 {
954- pkgVersionSuffix += expectedBuildMetadataWithoutCommitId ;
950+ string semVer1CommitPrefix = useSemVer2 ? string . Empty : "g" ;
951+ string pkgVersionSuffix = buildResult . PublicRelease ? string . Empty : $ "-{ semVer1CommitPrefix } { commitIdShort } ";
952+ if ( useSemVer2 )
953+ {
954+ pkgVersionSuffix += expectedBuildMetadataWithoutCommitId ;
955+ }
956+
957+ return pkgVersionSuffix ;
955958 }
956959
957- Assert . Equal ( $ "{ idAsVersion . Major } .{ idAsVersion . Minor } .{ idAsVersion . Build } { GetSemVerAppropriatePrereleaseTag ( versionOptions ) } { pkgVersionSuffix } ", buildResult . NuGetPackageVersion ) ;
960+ // NuGet is now SemVer 2.0 and will pass additional build metadata if provided
961+ string nugetPkgVersionSuffix = GetPkgVersionSuffix ( useSemVer2 : versionOptions ? . NuGetPackageVersionOrDefault . SemVer == 2 ) ;
962+ Assert . Equal ( $ "{ idAsVersion . Major } .{ idAsVersion . Minor } .{ idAsVersion . Build } { GetSemVerAppropriatePrereleaseTag ( versionOptions ) } { nugetPkgVersionSuffix } ", buildResult . NuGetPackageVersion ) ;
963+
964+ // Chocolatey only supports SemVer 1.0
965+ string chocolateyPkgVersionSuffix = GetPkgVersionSuffix ( useSemVer2 : false ) ;
966+ Assert . Equal ( $ "{ idAsVersion . Major } .{ idAsVersion . Minor } .{ idAsVersion . Build } { GetSemVerAppropriatePrereleaseTag ( versionOptions ) } { chocolateyPkgVersionSuffix } ", buildResult . ChocolateyPackageVersion ) ;
958967
959968 var buildNumberOptions = versionOptions . CloudBuildOrDefault . BuildNumberOrDefault ;
960969 if ( buildNumberOptions . EnabledOrDefault )
@@ -1137,6 +1146,7 @@ internal BuildResults(BuildResult buildResult, IReadOnlyList<BuildEventArgs> log
11371146 public string AssemblyFileVersion => this . BuildResult . ProjectStateAfterBuild . GetPropertyValue ( "AssemblyFileVersion" ) ;
11381147 public string AssemblyVersion => this . BuildResult . ProjectStateAfterBuild . GetPropertyValue ( "AssemblyVersion" ) ;
11391148 public string NuGetPackageVersion => this . BuildResult . ProjectStateAfterBuild . GetPropertyValue ( "NuGetPackageVersion" ) ;
1149+ public string ChocolateyPackageVersion => this . BuildResult . ProjectStateAfterBuild . GetPropertyValue ( "ChocolateyPackageVersion" ) ;
11401150 public string CloudBuildNumber => this . BuildResult . ProjectStateAfterBuild . GetPropertyValue ( "CloudBuildNumber" ) ;
11411151 public string AssemblyName => this . BuildResult . ProjectStateAfterBuild . GetPropertyValue ( "AssemblyName" ) ;
11421152 public string AssemblyTitle => this . BuildResult . ProjectStateAfterBuild . GetPropertyValue ( "AssemblyTitle" ) ;
0 commit comments