Skip to content

Commit c618356

Browse files
authored
Merge pull request #194 from microsoft/bugfix/semver-compare
fixes a bug where switch to semver versions would make comparison script fail
2 parents 99608e3 + c5506bb commit c618356

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

.azure-pipelines/ci-build.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ stages:
180180
inputs:
181181
targetType: 'filePath'
182182
filePath: $(System.DefaultWorkingDirectory)\scripts\ValidateProjectVersionUpdated.ps1
183-
arguments: '-projectVersion "$(VersionFullSemantic)"'
184183

185184
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
186185
displayName: 'ESRP CodeSigning Nuget Packages'

scripts/ValidateProjectVersionUpdated.ps1

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,28 @@
99
specified in the project file with the latest package version published on
1010
NuGet. If the version has not been updated, the script will fail and indicate
1111
that the project version neeeds to be updated.
12-
13-
.Parameter projectVersion
14-
Specifies the current project version. The project version currently is maintained
15-
in the versioning.props file
1612
#>
17-
18-
Param(
19-
[parameter(Mandatory = $true)]
20-
[string]$projectVersion
21-
)
22-
13+
Install-Module SemVerPS -Scope CurrentUser
2314
$packageName = "Microsoft.OpenApi.OData"
15+
$csprojPath = Join-Path $PSScriptRoot "..\src\Microsoft.OpenApi.OData.Reader\Microsoft.OpenAPI.OData.Reader.csproj"
16+
17+
[XML]$csprojFile = Get-Content $csprojPath
18+
$versionNode = Select-Xml $csprojFile -XPath "//Project/PropertyGroup/Version" | Select-Object -ExpandProperty Node
19+
$projectVersion = $versionNode.InnerText
2420

2521
# Cast the project version string to System.Version
26-
[version]$currentProjectVersion = $projectVersion
22+
$currentProjectVersion = ConvertTo-SemVer -Version $projectVersion
2723

2824
# API is case-sensitive
2925
$packageName = $packageName.ToLower()
30-
$url = "https://api.nuget.org/v3/registration5-semver1/$packageName/index.json"
26+
$url = "https://api.nuget.org/v3/registration5-gz-semver2/$packageName/index.json"
3127

3228
# Call the NuGet API for the package and get the current published version.
3329
$nugetIndex = Invoke-RestMethod -Uri $url -Method Get
3430
$publishedVersionString = $nugetIndex.items[0].upper
3531

3632
# Cast the published version string to System.Version
37-
[version]$currentPublishedVersion = $publishedVersionString
33+
$currentPublishedVersion = ConvertTo-SemVer -Version $publishedVersionString
3834

3935
# Validate that the version number has been updated.
4036
if ($currentProjectVersion -le $currentPublishedVersion) {

0 commit comments

Comments
 (0)