Skip to content

Commit

Permalink
Fix semver issue with updating cgmanifest (PowerShell#24132)
Browse files Browse the repository at this point in the history
  • Loading branch information
TravisEz13 authored Aug 9, 2024
1 parent 828c327 commit a90b03b
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 41 deletions.
56 changes: 28 additions & 28 deletions tools/cgmanifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"$schema": "https://json.schemastore.org/component-detection-manifest.json",
"Registrations": [
{
"Component": {
Expand Down Expand Up @@ -36,7 +35,7 @@
"Type": "nuget",
"Nuget": {
"Name": "Json.More.Net",
"Version": "2.0.0"
"Version": "2.0.1.2"
}
},
"DevelopmentDependency": false
Expand All @@ -46,7 +45,7 @@
"Type": "nuget",
"Nuget": {
"Name": "JsonPointer.Net",
"Version": "4.0.0"
"Version": "5.0.0"
}
},
"DevelopmentDependency": false
Expand All @@ -56,7 +55,7 @@
"Type": "nuget",
"Nuget": {
"Name": "JsonSchema.Net",
"Version": "6.0.2"
"Version": "7.0.1"
}
},
"DevelopmentDependency": false
Expand All @@ -66,7 +65,7 @@
"Type": "nuget",
"Nuget": {
"Name": "Markdig.Signed",
"Version": "0.34.0"
"Version": "0.37.0"
}
},
"DevelopmentDependency": false
Expand All @@ -86,7 +85,7 @@
"Type": "nuget",
"Nuget": {
"Name": "Microsoft.Bcl.AsyncInterfaces",
"Version": "5.0.0"
"Version": "8.0.0"
}
},
"DevelopmentDependency": false
Expand All @@ -106,7 +105,7 @@
"Type": "nuget",
"Nuget": {
"Name": "Microsoft.CodeAnalysis.Common",
"Version": "4.8.0"
"Version": "4.9.2"
}
},
"DevelopmentDependency": false
Expand All @@ -116,7 +115,7 @@
"Type": "nuget",
"Nuget": {
"Name": "Microsoft.CodeAnalysis.CSharp",
"Version": "4.8.0"
"Version": "4.9.2"
}
},
"DevelopmentDependency": false
Expand All @@ -126,7 +125,7 @@
"Type": "nuget",
"Nuget": {
"Name": "Microsoft.Extensions.ObjectPool",
"Version": "5.0.10"
"Version": "8.0.4"
}
},
"DevelopmentDependency": false
Expand Down Expand Up @@ -226,7 +225,7 @@
"Type": "nuget",
"Nuget": {
"Name": "Microsoft.Windows.Compatibility",
"Version": "8.0.2"
"Version": "8.0.7"
}
},
"DevelopmentDependency": false
Expand All @@ -246,7 +245,7 @@
"Type": "nuget",
"Nuget": {
"Name": "runtime.android-arm.runtime.native.System.IO.Ports",
"Version": "9.0.0-preview.1.24080.9"
"Version": "9.0.0-preview.3.24172.9"
}
},
"DevelopmentDependency": false
Expand All @@ -256,7 +255,7 @@
"Type": "nuget",
"Nuget": {
"Name": "runtime.android-arm64.runtime.native.System.IO.Ports",
"Version": "9.0.0-preview.1.24080.9"
"Version": "9.0.0-preview.3.24172.9"
}
},
"DevelopmentDependency": false
Expand All @@ -266,7 +265,7 @@
"Type": "nuget",
"Nuget": {
"Name": "runtime.android-x64.runtime.native.System.IO.Ports",
"Version": "9.0.0-preview.1.24080.9"
"Version": "9.0.0-preview.3.24172.9"
}
},
"DevelopmentDependency": false
Expand All @@ -276,7 +275,7 @@
"Type": "nuget",
"Nuget": {
"Name": "runtime.android-x86.runtime.native.System.IO.Ports",
"Version": "9.0.0-preview.1.24080.9"
"Version": "9.0.0-preview.3.24172.9"
}
},
"DevelopmentDependency": false
Expand Down Expand Up @@ -306,7 +305,7 @@
"Type": "nuget",
"Nuget": {
"Name": "runtime.linux-bionic-arm64.runtime.native.System.IO.Ports",
"Version": "9.0.0-preview.1.24080.9"
"Version": "9.0.0-preview.3.24172.9"
}
},
"DevelopmentDependency": false
Expand All @@ -316,7 +315,7 @@
"Type": "nuget",
"Nuget": {
"Name": "runtime.linux-bionic-x64.runtime.native.System.IO.Ports",
"Version": "9.0.0-preview.1.24080.9"
"Version": "9.0.0-preview.3.24172.9"
}
},
"DevelopmentDependency": false
Expand All @@ -326,7 +325,7 @@
"Type": "nuget",
"Nuget": {
"Name": "runtime.linux-musl-arm.runtime.native.System.IO.Ports",
"Version": "9.0.0-preview.1.24080.9"
"Version": "9.0.0-preview.3.24172.9"
}
},
"DevelopmentDependency": false
Expand All @@ -336,7 +335,7 @@
"Type": "nuget",
"Nuget": {
"Name": "runtime.linux-musl-arm64.runtime.native.System.IO.Ports",
"Version": "9.0.0-preview.1.24080.9"
"Version": "9.0.0-preview.3.24172.9"
}
},
"DevelopmentDependency": false
Expand All @@ -346,7 +345,7 @@
"Type": "nuget",
"Nuget": {
"Name": "runtime.linux-musl-x64.runtime.native.System.IO.Ports",
"Version": "9.0.0-preview.1.24080.9"
"Version": "9.0.0-preview.3.24172.9"
}
},
"DevelopmentDependency": false
Expand All @@ -366,7 +365,7 @@
"Type": "nuget",
"Nuget": {
"Name": "runtime.maccatalyst-arm64.runtime.native.System.IO.Ports",
"Version": "9.0.0-preview.1.24080.9"
"Version": "9.0.0-preview.3.24172.9"
}
},
"DevelopmentDependency": false
Expand All @@ -376,7 +375,7 @@
"Type": "nuget",
"Nuget": {
"Name": "runtime.maccatalyst-x64.runtime.native.System.IO.Ports",
"Version": "9.0.0-preview.1.24080.9"
"Version": "9.0.0-preview.3.24172.9"
}
},
"DevelopmentDependency": false
Expand Down Expand Up @@ -556,7 +555,7 @@
"Type": "nuget",
"Nuget": {
"Name": "System.Diagnostics.DiagnosticSource",
"Version": "8.0.0"
"Version": "8.0.1"
}
},
"DevelopmentDependency": false
Expand Down Expand Up @@ -616,7 +615,7 @@
"Type": "nuget",
"Nuget": {
"Name": "System.Drawing.Common",
"Version": "8.0.2"
"Version": "8.0.7"
}
},
"DevelopmentDependency": false
Expand All @@ -626,7 +625,7 @@
"Type": "nuget",
"Nuget": {
"Name": "System.Formats.Asn1",
"Version": "8.0.0"
"Version": "8.0.1"
}
},
"DevelopmentDependency": false
Expand Down Expand Up @@ -666,7 +665,7 @@
"Type": "nuget",
"Nuget": {
"Name": "System.Net.Http.WinHttpHandler",
"Version": "8.0.0"
"Version": "8.0.1"
}
},
"DevelopmentDependency": false
Expand Down Expand Up @@ -746,7 +745,7 @@
"Type": "nuget",
"Nuget": {
"Name": "System.Security.AccessControl",
"Version": "6.0.0"
"Version": "6.0.1"
}
},
"DevelopmentDependency": false
Expand Down Expand Up @@ -776,7 +775,7 @@
"Type": "nuget",
"Nuget": {
"Name": "System.Security.Cryptography.Xml",
"Version": "8.0.0"
"Version": "8.0.1"
}
},
"DevelopmentDependency": false
Expand Down Expand Up @@ -931,5 +930,6 @@
},
"DevelopmentDependency": false
}
]
],
"$schema": "https://json.schemastore.org/component-detection-manifest.json"
}
40 changes: 27 additions & 13 deletions tools/findMissingNotices.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,28 @@ if (!$IsWindows) {
Write-Warning "Always using $winDesktopSdk since this is not windows!!!"
}

function ConvertTo-SemVer {
param(
[String] $Version
)

[System.Management.Automation.SemanticVersion]$desiredVersion = [System.Management.Automation.SemanticVersion]::Empty

try {
$desiredVersion = $Version
} catch {
<#
Json.More.Net broke the rules and published 2.0.1.2 as 2.0.1.
So, I'm making the logic work for that scenario by
thorwing away any part that doesn't match non-pre-release semver portion
#>
$null = $Version -match '^(\d+\.\d+\.\d+)).*'
$desiredVersion = $matches[1]
}

return $desiredVersion
}

function New-NugetComponent {
param(
[string]$name,
Expand Down Expand Up @@ -125,23 +147,15 @@ function Get-NuGetPublicVersion {
return $nugetPublicVersionCache[$Name]
}

try {
[System.Management.Automation.SemanticVersion]$desiredVersion = $Version
} catch {
[Version]$desiredVersion = $Version
}
[System.Management.Automation.SemanticVersion]$desiredVersion = ConvertTo-SemVer -Version $Version

$publicVersion = $null
$publicVersion = Find-Package -Name $Name -AllowPrereleaseVersions -source $packageSourceName -AllVersions -ErrorAction SilentlyContinue | ForEach-Object {
try {
$packageVersion = [System.Management.Automation.SemanticVersion]$_.Version
} catch {
# Fall back to using [version] if it is not a semantic version
$packageVersion = $_.Version
}

[System.Management.Automation.SemanticVersion]$packageVersion = ConvertTo-SemVer -Version $_.Version
$_ | Add-Member -Name SemVer -MemberType NoteProperty -Value $packageVersion -PassThru
} | Where-Object { $_.SemVer -le $desiredVersion } | Sort-Object -Property semver -Descending | Select-Object -First 1 -ExpandProperty Version
} | Where-Object {
$_.SemVer -le $desiredVersion
} | Sort-Object -Property semver -Descending | Select-Object -First 1 -ExpandProperty Version

if(!$publicVersion) {
Write-Warning "No public version found for $Name, using $Version"
Expand Down

0 comments on commit a90b03b

Please sign in to comment.