Fix semver issue with updating cgmanifest (#24132)

This commit is contained in:
Travis Plunk
2024-08-09 18:58:35 +00:00
committed by GitHub
parent 828c32709c
commit a90b03b428
2 changed files with 55 additions and 41 deletions
+28 -28
View File
@@ -1,5 +1,4 @@
{
"$schema": "https://json.schemastore.org/component-detection-manifest.json",
"Registrations": [
{
"Component": {
@@ -36,7 +35,7 @@
"Type": "nuget",
"Nuget": {
"Name": "Json.More.Net",
"Version": "2.0.0"
"Version": "2.0.1.2"
}
},
"DevelopmentDependency": false
@@ -46,7 +45,7 @@
"Type": "nuget",
"Nuget": {
"Name": "JsonPointer.Net",
"Version": "4.0.0"
"Version": "5.0.0"
}
},
"DevelopmentDependency": false
@@ -56,7 +55,7 @@
"Type": "nuget",
"Nuget": {
"Name": "JsonSchema.Net",
"Version": "6.0.2"
"Version": "7.0.1"
}
},
"DevelopmentDependency": false
@@ -66,7 +65,7 @@
"Type": "nuget",
"Nuget": {
"Name": "Markdig.Signed",
"Version": "0.34.0"
"Version": "0.37.0"
}
},
"DevelopmentDependency": false
@@ -86,7 +85,7 @@
"Type": "nuget",
"Nuget": {
"Name": "Microsoft.Bcl.AsyncInterfaces",
"Version": "5.0.0"
"Version": "8.0.0"
}
},
"DevelopmentDependency": false
@@ -106,7 +105,7 @@
"Type": "nuget",
"Nuget": {
"Name": "Microsoft.CodeAnalysis.Common",
"Version": "4.8.0"
"Version": "4.9.2"
}
},
"DevelopmentDependency": false
@@ -116,7 +115,7 @@
"Type": "nuget",
"Nuget": {
"Name": "Microsoft.CodeAnalysis.CSharp",
"Version": "4.8.0"
"Version": "4.9.2"
}
},
"DevelopmentDependency": false
@@ -126,7 +125,7 @@
"Type": "nuget",
"Nuget": {
"Name": "Microsoft.Extensions.ObjectPool",
"Version": "5.0.10"
"Version": "8.0.4"
}
},
"DevelopmentDependency": false
@@ -226,7 +225,7 @@
"Type": "nuget",
"Nuget": {
"Name": "Microsoft.Windows.Compatibility",
"Version": "8.0.2"
"Version": "8.0.7"
}
},
"DevelopmentDependency": false
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -556,7 +555,7 @@
"Type": "nuget",
"Nuget": {
"Name": "System.Diagnostics.DiagnosticSource",
"Version": "8.0.0"
"Version": "8.0.1"
}
},
"DevelopmentDependency": false
@@ -616,7 +615,7 @@
"Type": "nuget",
"Nuget": {
"Name": "System.Drawing.Common",
"Version": "8.0.2"
"Version": "8.0.7"
}
},
"DevelopmentDependency": false
@@ -626,7 +625,7 @@
"Type": "nuget",
"Nuget": {
"Name": "System.Formats.Asn1",
"Version": "8.0.0"
"Version": "8.0.1"
}
},
"DevelopmentDependency": false
@@ -666,7 +665,7 @@
"Type": "nuget",
"Nuget": {
"Name": "System.Net.Http.WinHttpHandler",
"Version": "8.0.0"
"Version": "8.0.1"
}
},
"DevelopmentDependency": false
@@ -746,7 +745,7 @@
"Type": "nuget",
"Nuget": {
"Name": "System.Security.AccessControl",
"Version": "6.0.0"
"Version": "6.0.1"
}
},
"DevelopmentDependency": false
@@ -776,7 +775,7 @@
"Type": "nuget",
"Nuget": {
"Name": "System.Security.Cryptography.Xml",
"Version": "8.0.0"
"Version": "8.0.1"
}
},
"DevelopmentDependency": false
@@ -931,5 +930,6 @@
},
"DevelopmentDependency": false
}
]
],
"$schema": "https://json.schemastore.org/component-detection-manifest.json"
}
+27 -13
View File
@@ -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,
@@ -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"