Fix CloudBuildAllVars value formatting #882
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As mentioned in #876 (comment), the formatting of the
CloudBuildAllVarsvalues used the current culture and didn't specify a format for date values, causing the format to change based on the current culture and not be consistent (between systems/build servers).Although currently only the
GitCommitDatevalue is affected, I've ensured the code also uses the invariant culture for other types (e.g. in case a decimal value is added in the future). I've also ignored theVersionOptionsproperty, since that isn't a simple value type and other complex values aren't outputted as well (likeBuildMetadataWithCommitIdandBuildMetadata).Before this PR,
nbgv.exe get-version -f jsonwould output the following:{ // ... "CloudBuildAllVars": { "NBGV_CloudBuildNumber": "3.6.72-alpha", "NBGV_VersionFileFound": "True", "NBGV_VersionOptions": "Nerdbank.GitVersioning.VersionOptions", "NBGV_AssemblyVersion": "3.6.72.10058", "NBGV_AssemblyFileVersion": "3.6.72.10058", "NBGV_AssemblyInformationalVersion": "3.6.72-alpha+274a42ed33", "NBGV_PublicRelease": "True", "NBGV_PrereleaseVersion": "-alpha", "NBGV_PrereleaseVersionNoLeadingHyphen": "alpha", "NBGV_SimpleVersion": "3.6.72", "NBGV_BuildNumber": "72", "NBGV_VersionRevision": "10058", "NBGV_MajorMinorVersion": "3.6", "NBGV_VersionMajor": "3", "NBGV_VersionMinor": "6", "NBGV_GitCommitId": "274a42ed3321bcc43632dc970d65677f99a486a9", "NBGV_GitCommitIdShort": "274a42ed33", "NBGV_GitCommitDate": "5-12-2022 23:22:02 +00:00", "NBGV_VersionHeight": "72", "NBGV_VersionHeightOffset": "0", "NBGV_BuildingRef": "refs/heads/main", "NBGV_Version": "3.6.72.10058", "NBGV_BuildMetadataFragment": "+274a42ed33", "NBGV_NuGetPackageVersion": "3.6.72-alpha", "NBGV_ChocolateyPackageVersion": "3.6.72-alpha", "NBGV_NpmPackageVersion": "3.6.72-alpha", "NBGV_SemVer1": "3.6.72-alpha", "NBGV_SemVer2": "3.6.72-alpha", "NBGV_SemVer1NumericIdentifierPadding": "4" }, // ... }With this PR applied, you'll notice the
NBGV_VersionOptionsis not present anymore andNBGV_GitCommitDatecontains an ISO 8601 date format:{ // ... "CloudBuildAllVars": { "NBGV_CloudBuildNumber": "3.6.73-alpha+03e9883256", "NBGV_VersionFileFound": "True", "NBGV_AssemblyVersion": "3.6.73.1001", "NBGV_AssemblyFileVersion": "3.6.73.1001", "NBGV_AssemblyInformationalVersion": "3.6.73-alpha+03e9883256", "NBGV_PublicRelease": "False", "NBGV_PrereleaseVersion": "-alpha", "NBGV_PrereleaseVersionNoLeadingHyphen": "alpha", "NBGV_SimpleVersion": "3.6.73", "NBGV_BuildNumber": "73", "NBGV_VersionRevision": "1001", "NBGV_MajorMinorVersion": "3.6", "NBGV_VersionMajor": "3", "NBGV_VersionMinor": "6", "NBGV_GitCommitId": "03e988325666cd92193afb2ce5b10688276d9ee3", "NBGV_GitCommitIdShort": "03e9883256", "NBGV_GitCommitDate": "2023-01-04T09:22:10+00:00", "NBGV_VersionHeight": "73", "NBGV_VersionHeightOffset": "0", "NBGV_BuildingRef": "refs/heads/feature/cloudbuildallvars-formatting", "NBGV_Version": "3.6.73.1001", "NBGV_BuildMetadataFragment": "+03e9883256", "NBGV_NuGetPackageVersion": "3.6.73-alpha-g03e9883256", "NBGV_ChocolateyPackageVersion": "3.6.73-alpha-g03e9883256", "NBGV_NpmPackageVersion": "3.6.73-alpha.g03e9883256", "NBGV_SemVer1": "3.6.73-alpha-03e9883256", "NBGV_SemVer2": "3.6.73-alpha.g03e9883256", "NBGV_SemVer1NumericIdentifierPadding": "4" }, // ... }