From 64392f36d17ba181db217cf6734a4cc741f8bf0f Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Mon, 1 Nov 2021 10:25:39 -0700 Subject: [PATCH] Generate manifest with latest public version of the packages (#16337) * Generate manifest with latest public version of the packages * update cgmanifest * update the PR title for the notice update * Fix code factor issue - use catch block for fall back * removing noisy logging --- .github/workflows/daily.yml | 4 +- cgmanifest.json | 96 ++++++++++++++++++------------------ tools/findMissingNotices.ps1 | 56 ++++++++++++++++++--- 3 files changed, 99 insertions(+), 57 deletions(-) diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml index c71533a3e0..bd1a352d0f 100644 --- a/.github/workflows/daily.yml +++ b/.github/workflows/daily.yml @@ -71,10 +71,10 @@ jobs: uses: peter-evans/create-pull-request@v3 id: cprtpn with: - commit-message: "Update to the latest license and the cgmanifest with missing or updated components" + commit-message: "Update to the latest notice file" committer: GitHub author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> - title: "Update to the latest license and the cgmanifest with missing or updated components" + title: "Update to the latest notice file" reviewers: travisez13 base: master draft: false diff --git a/cgmanifest.json b/cgmanifest.json index 9ae862d627..486e39fa48 100644 --- a/cgmanifest.json +++ b/cgmanifest.json @@ -85,7 +85,7 @@ "Type": "nuget", "Nuget": { "Name": "Microsoft.CodeAnalysis.NetAnalyzers", - "Version": "6.0.0" + "Version": "5.0.3" } }, "DevelopmentDependency": true @@ -195,7 +195,7 @@ "Type": "nuget", "Nuget": { "Name": "Microsoft.Win32.Registry.AccessControl", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -215,7 +215,7 @@ "Type": "nuget", "Nuget": { "Name": "Microsoft.Win32.SystemEvents", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -225,7 +225,7 @@ "Type": "nuget", "Nuget": { "Name": "Microsoft.Windows.Compatibility", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -415,7 +415,7 @@ "Type": "nuget", "Nuget": { "Name": "runtime.linux-arm.runtime.native.System.IO.Ports", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -425,7 +425,7 @@ "Type": "nuget", "Nuget": { "Name": "runtime.linux-arm64.runtime.native.System.IO.Ports", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -435,7 +435,7 @@ "Type": "nuget", "Nuget": { "Name": "runtime.linux-x64.runtime.native.System.IO.Ports", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -455,7 +455,7 @@ "Type": "nuget", "Nuget": { "Name": "runtime.native.System.IO.Ports", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -525,7 +525,7 @@ "Type": "nuget", "Nuget": { "Name": "runtime.osx-x64.runtime.native.System.IO.Ports", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -705,7 +705,7 @@ "Type": "nuget", "Nuget": { "Name": "System.CodeDom", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -735,7 +735,7 @@ "Type": "nuget", "Nuget": { "Name": "System.ComponentModel.Composition.Registration", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -745,7 +745,7 @@ "Type": "nuget", "Nuget": { "Name": "System.ComponentModel.Composition", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -755,7 +755,7 @@ "Type": "nuget", "Nuget": { "Name": "System.Configuration.ConfigurationManager", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -765,7 +765,7 @@ "Type": "nuget", "Nuget": { "Name": "System.Data.Odbc", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -775,7 +775,7 @@ "Type": "nuget", "Nuget": { "Name": "System.Data.OleDb", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -815,7 +815,7 @@ "Type": "nuget", "Nuget": { "Name": "System.Diagnostics.EventLog", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -825,7 +825,7 @@ "Type": "nuget", "Nuget": { "Name": "System.Diagnostics.PerformanceCounter", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -835,7 +835,7 @@ "Type": "nuget", "Nuget": { "Name": "System.DirectoryServices.AccountManagement", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -845,7 +845,7 @@ "Type": "nuget", "Nuget": { "Name": "System.DirectoryServices.Protocols", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -855,7 +855,7 @@ "Type": "nuget", "Nuget": { "Name": "System.DirectoryServices", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -865,7 +865,7 @@ "Type": "nuget", "Nuget": { "Name": "System.Drawing.Common", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -885,7 +885,7 @@ "Type": "nuget", "Nuget": { "Name": "System.Formats.Asn1", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -905,7 +905,7 @@ "Type": "nuget", "Nuget": { "Name": "System.IO.Packaging", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -915,7 +915,7 @@ "Type": "nuget", "Nuget": { "Name": "System.IO.Ports", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -955,7 +955,7 @@ "Type": "nuget", "Nuget": { "Name": "System.Management", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -975,7 +975,7 @@ "Type": "nuget", "Nuget": { "Name": "System.Net.Http.WinHttpHandler", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -1005,7 +1005,7 @@ "Type": "nuget", "Nuget": { "Name": "System.Private.ServiceModel", - "Version": "4.9.0" + "Version": "4.9.0-rc2.21473.1" } }, "DevelopmentDependency": false @@ -1025,7 +1025,7 @@ "Type": "nuget", "Nuget": { "Name": "System.Reflection.Context", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -1135,7 +1135,7 @@ "Type": "nuget", "Nuget": { "Name": "System.Runtime.Caching", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -1145,7 +1145,7 @@ "Type": "nuget", "Nuget": { "Name": "System.Runtime.CompilerServices.Unsafe", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -1195,7 +1195,7 @@ "Type": "nuget", "Nuget": { "Name": "System.Security.AccessControl", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -1205,7 +1205,7 @@ "Type": "nuget", "Nuget": { "Name": "System.Security.Cryptography.Pkcs", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -1215,7 +1215,7 @@ "Type": "nuget", "Nuget": { "Name": "System.Security.Cryptography.ProtectedData", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -1225,7 +1225,7 @@ "Type": "nuget", "Nuget": { "Name": "System.Security.Cryptography.Xml", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -1235,7 +1235,7 @@ "Type": "nuget", "Nuget": { "Name": "System.Security.Permissions", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -1255,7 +1255,7 @@ "Type": "nuget", "Nuget": { "Name": "System.ServiceModel.Duplex", - "Version": "4.9.0" + "Version": "4.9.0-rc2.21473.1" } }, "DevelopmentDependency": false @@ -1265,7 +1265,7 @@ "Type": "nuget", "Nuget": { "Name": "System.ServiceModel.Http", - "Version": "4.9.0" + "Version": "4.9.0-rc2.21473.1" } }, "DevelopmentDependency": false @@ -1275,7 +1275,7 @@ "Type": "nuget", "Nuget": { "Name": "System.ServiceModel.NetTcp", - "Version": "4.9.0" + "Version": "4.9.0-rc2.21473.1" } }, "DevelopmentDependency": false @@ -1285,7 +1285,7 @@ "Type": "nuget", "Nuget": { "Name": "System.ServiceModel.Primitives", - "Version": "4.9.0" + "Version": "4.9.0-rc2.21473.1" } }, "DevelopmentDependency": false @@ -1295,7 +1295,7 @@ "Type": "nuget", "Nuget": { "Name": "System.ServiceModel.Security", - "Version": "4.9.0" + "Version": "4.9.0-rc2.21473.1" } }, "DevelopmentDependency": false @@ -1305,7 +1305,7 @@ "Type": "nuget", "Nuget": { "Name": "System.ServiceModel.Syndication", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -1315,7 +1315,7 @@ "Type": "nuget", "Nuget": { "Name": "System.ServiceProcess.ServiceController", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -1325,7 +1325,7 @@ "Type": "nuget", "Nuget": { "Name": "System.Speech", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -1335,7 +1335,7 @@ "Type": "nuget", "Nuget": { "Name": "System.Text.Encoding.CodePages", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -1355,7 +1355,7 @@ "Type": "nuget", "Nuget": { "Name": "System.Text.Encodings.Web", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -1365,7 +1365,7 @@ "Type": "nuget", "Nuget": { "Name": "System.Threading.AccessControl", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false @@ -1405,7 +1405,7 @@ "Type": "nuget", "Nuget": { "Name": "System.Web.Services.Description", - "Version": "4.9.0" + "Version": "4.9.0-rc2.21473.1" } }, "DevelopmentDependency": false @@ -1415,7 +1415,7 @@ "Type": "nuget", "Nuget": { "Name": "System.Windows.Extensions", - "Version": "6.0.0" + "Version": "6.0.0-rc.2.21480.5" } }, "DevelopmentDependency": false diff --git a/tools/findMissingNotices.ps1 b/tools/findMissingNotices.ps1 index b8f7231b96..f66f88f129 100644 --- a/tools/findMissingNotices.ps1 +++ b/tools/findMissingNotices.ps1 @@ -75,6 +75,12 @@ Class Nuget { } } +$winDesktopSdk = 'Microsoft.NET.Sdk.WindowsDesktop' +if (!$IsWindows) { + $winDesktopSdk = 'Microsoft.NET.Sdk' + Write-Warning "Always using $winDesktopSdk since this is not windows!!!" +} + function New-NugetComponent { param( [string]$name, @@ -99,13 +105,48 @@ function New-NugetComponent { return $registration } -$winDesktopSdk = 'Microsoft.NET.Sdk.WindowsDesktop' -if (!$IsWindows) { - $winDesktopSdk = 'Microsoft.NET.Sdk' - Write-Warning "Always using $winDesktopSdk since this is not windows!!!" +$nugetPublicVersionCache = [System.Collections.Generic.Dictionary[string, string]]::new() +function Get-NuGetPublicVersion { + param( + [string]$Name, + [string]$Version + ) + + if($nugetPublicVersionCache.ContainsKey($Name)) { + return $nugetPublicVersionCache[$Name] + } + + try { + [System.Management.Automation.SemanticVersion]$desiredVersion = $Version + } catch { + [Version]$desiredVersion = $Version + } + + $publicVersion = $null + $publicVersion = Find-Package -Name $Name -AllowPrereleaseVersions -source nuget.org -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 + } + + $_ | 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 + + if(!$publicVersion) { + Write-Warning "No public version found for $Name, using $Version" + $publicVersion = $Version + } + + if(!$nugetPublicVersionCache.ContainsKey($Name)) { + $nugetPublicVersionCache.Add($Name, $publicVersion) + } + + return $publicVersion } -Function Get-CGRegistrations { +function Get-CGRegistrations { param( [Parameter(Mandatory)] [ValidateSet( @@ -190,20 +231,21 @@ Function Get-CGRegistrations { $parts = ($target -split '\|') $name = $parts[0] $targetVersion = $parts[1] + $publicVersion = Get-NuGetPublicVersion -Name $name -Version $targetVersion # Add the registration to the cgmanifest if the TPN does not contain the name of the target OR # the exisitng CG contains the registration, because if the existing CG contains the registration, # that might be the only reason it is in the TPN. if (!$RegistrationTable.ContainsKey($target)) { $DevelopmentDependency = $false - if (!$existingRegistrationTable.ContainsKey($name) -or $existingRegistrationTable.$name.Component.Version() -ne $targetVersion) { + if (!$existingRegistrationTable.ContainsKey($name) -or $existingRegistrationTable.$name.Component.Version() -ne $publicVersion) { $registrationChanged = $true } if ($existingRegistrationTable.ContainsKey($name) -and $existingRegistrationTable.$name.DevelopmentDependency) { $DevelopmentDependency = $true } - $registration = New-NugetComponent -Name $name -Version $targetVersion -DevelopmentDependency:$DevelopmentDependency + $registration = New-NugetComponent -Name $name -Version $publicVersion -DevelopmentDependency:$DevelopmentDependency $RegistrationTable.Add($target, $registration) } }