|
9 | 9 | specified in the project file with the latest package version published on
|
10 | 10 | NuGet. If the version has not been updated, the script will fail and indicate
|
11 | 11 | 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 |
16 | 12 | #>
|
17 |
| - |
18 |
| -Param( |
19 |
| - [parameter(Mandatory = $true)] |
20 |
| - [string]$projectVersion |
21 |
| -) |
22 |
| - |
| 13 | +Install-Module SemVerPS -Scope CurrentUser |
23 | 14 | $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 |
24 | 20 |
|
25 | 21 | # Cast the project version string to System.Version
|
26 |
| -[version]$currentProjectVersion = $projectVersion |
| 22 | +$currentProjectVersion = ConvertTo-SemVer -Version $projectVersion |
27 | 23 |
|
28 | 24 | # API is case-sensitive
|
29 | 25 | $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" |
31 | 27 |
|
32 | 28 | # Call the NuGet API for the package and get the current published version.
|
33 | 29 | $nugetIndex = Invoke-RestMethod -Uri $url -Method Get
|
34 | 30 | $publishedVersionString = $nugetIndex.items[0].upper
|
35 | 31 |
|
36 | 32 | # Cast the published version string to System.Version
|
37 |
| -[version]$currentPublishedVersion = $publishedVersionString |
| 33 | +$currentPublishedVersion = ConvertTo-SemVer -Version $publishedVersionString |
38 | 34 |
|
39 | 35 | # Validate that the version number has been updated.
|
40 | 36 | if ($currentProjectVersion -le $currentPublishedVersion) {
|
|
0 commit comments