From de1a86d8f4b67a6fdd7ecc8578b30eadf10f3a7c Mon Sep 17 00:00:00 2001 From: "Gavin Barron (from Dev Box)" Date: Tue, 4 Aug 2026 17:48:52 -0700 Subject: [PATCH 1/3] fix(ci): avoid blocked NuGet registration endpoint Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 03d194c7-5fba-4802-a182-3b3ef5c5c0ab --- scripts/ValidateUpdatedNugetVersion.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/ValidateUpdatedNugetVersion.ps1 b/scripts/ValidateUpdatedNugetVersion.ps1 index a66ad5d16b2..0ff9b159db5 100644 --- a/scripts/ValidateUpdatedNugetVersion.ps1 +++ b/scripts/ValidateUpdatedNugetVersion.ps1 @@ -40,7 +40,7 @@ $currentProjectVersion = [System.Management.Automation.SemanticVersion]"$version # API is case-sensitive $packageName = $packageName.ToLower() -$url = "https://api.nuget.org/v3/registration5-gz-semver2/$packageName/index.json" +$url = "https://azuresearch-usnc.nuget.org/query?q=packageid:$packageName&prerelease=true&semVerLevel=2.0.0" # Call the NuGet API for the package and get the current published version. Try { @@ -56,7 +56,7 @@ Catch { Exit 1 } -$currentPublishedVersion = [System.Management.Automation.SemanticVersion]$nugetIndex.items[$nugetIndex.items.Count-1].upper +$currentPublishedVersion = [System.Management.Automation.SemanticVersion]$nugetIndex.data[0].version # Validate that the version number has been updated. if ($currentProjectVersion -le $currentPublishedVersion) { From db8890b5f255063f3f984d0fa9ac86393bd3efba Mon Sep 17 00:00:00 2001 From: "Gavin Barron (from Dev Box)" Date: Tue, 4 Aug 2026 18:04:33 -0700 Subject: [PATCH 2/3] fix(ci): route NuGet version check through CFS Replace the direct public NuGet API request with dotnet package search using the authenticated Central Feed Service configuration. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 03d194c7-5fba-4802-a182-3b3ef5c5c0ab --- .azure-pipelines/ci-build.yml | 2 +- scripts/ValidateUpdatedNugetVersion.ps1 | 33 +++++++++++++++---------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 672647cc473..35da8dd9e40 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -144,7 +144,7 @@ extends: inputs: targetType: filePath filePath: '$(Build.SourcesDirectory)\scripts\ValidateUpdatedNugetVersion.ps1' - arguments: '-packageName "Microsoft.Graph" -projectPath "$(Build.SourcesDirectory)\src\Microsoft.Graph\Microsoft.Graph.csproj"' + arguments: '-packageName "Microsoft.Graph" -projectPath "$(Build.SourcesDirectory)\src\Microsoft.Graph\Microsoft.Graph.csproj" -nugetConfigPath "$(Build.SourcesDirectory)\nuget.config"' pwsh: true enabled: true - task: EsrpCodeSigning@5 diff --git a/scripts/ValidateUpdatedNugetVersion.ps1 b/scripts/ValidateUpdatedNugetVersion.ps1 index 0ff9b159db5..519526a8148 100644 --- a/scripts/ValidateUpdatedNugetVersion.ps1 +++ b/scripts/ValidateUpdatedNugetVersion.ps1 @@ -16,6 +16,9 @@ .Parameter projectPath Specifies the path to the project file. + +.Parameter nugetConfigPath + Specifies the path to the NuGet configuration for the Central Feed Service. #> Param( @@ -23,7 +26,10 @@ Param( [string]$packageName, [parameter(Mandatory = $true)] - [string]$projectPath + [string]$projectPath, + + [parameter(Mandatory = $true)] + [string]$nugetConfigPath ) [xml]$xmlDoc = Get-Content $projectPath @@ -38,25 +44,26 @@ if($xmlDoc.Project.PropertyGroup[0].VersionSuffix){ # System.Version, get the version prefix. $currentProjectVersion = [System.Management.Automation.SemanticVersion]"$versionPrefixString" -# API is case-sensitive -$packageName = $packageName.ToLower() -$url = "https://azuresearch-usnc.nuget.org/query?q=packageid:$packageName&prerelease=true&semVerLevel=2.0.0" - -# Call the NuGet API for the package and get the current published version. Try { - $nugetIndex = Invoke-RestMethod -Uri $url -Method Get + $searchResultJson = dotnet package search $packageName --configfile $nugetConfigPath --exact-match --prerelease --format json + if ($LASTEXITCODE -ne 0) { + throw "dotnet package search exited with code $LASTEXITCODE" + } + + $searchResult = $searchResultJson | ConvertFrom-Json + $matchingPackages = $searchResult.searchResult | ForEach-Object { $_.packages } | Where-Object { $_.id -ieq $packageName } } Catch { - if ($_.ErrorDetails.Message && $_.ErrorDetails.Message.Contains("The specified blob does not exist.")) { - Write-Host "No package exists. You will probably be publishing $packageName for the first time." - Exit # exit gracefully - } - Write-Host $_ Exit 1 } -$currentPublishedVersion = [System.Management.Automation.SemanticVersion]$nugetIndex.data[0].version +if (-not $matchingPackages) { + Write-Host "No package exists. You will probably be publishing $packageName for the first time." + Exit # exit gracefully +} + +$currentPublishedVersion = ($matchingPackages | ForEach-Object { [System.Management.Automation.SemanticVersion]$_.version } | Sort-Object)[-1] # Validate that the version number has been updated. if ($currentProjectVersion -le $currentPublishedVersion) { From a68004ddf9db990bce93234572a591ac102dad5e Mon Sep 17 00:00:00 2001 From: "Gavin Barron (from Dev Box)" Date: Tue, 4 Aug 2026 18:13:07 -0700 Subject: [PATCH 3/3] fix(ci): parse package search JSON as one document Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 03d194c7-5fba-4802-a182-3b3ef5c5c0ab --- scripts/ValidateUpdatedNugetVersion.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ValidateUpdatedNugetVersion.ps1 b/scripts/ValidateUpdatedNugetVersion.ps1 index 519526a8148..034206f5039 100644 --- a/scripts/ValidateUpdatedNugetVersion.ps1 +++ b/scripts/ValidateUpdatedNugetVersion.ps1 @@ -45,7 +45,7 @@ if($xmlDoc.Project.PropertyGroup[0].VersionSuffix){ $currentProjectVersion = [System.Management.Automation.SemanticVersion]"$versionPrefixString" Try { - $searchResultJson = dotnet package search $packageName --configfile $nugetConfigPath --exact-match --prerelease --format json + $searchResultJson = dotnet package search $packageName --configfile $nugetConfigPath --exact-match --prerelease --format json | Out-String if ($LASTEXITCODE -ne 0) { throw "dotnet package search exited with code $LASTEXITCODE" }