Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions .github/scripts/Update-DotNetSdkVersions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -267,23 +267,21 @@ function Get-LatestPackageVersion {
)

try {
$prereleaseFlag = if ($IncludePrerelease) { "--prerelease" } else { "" }

# Check for NuGet configuration files in the sources directory
$configSourceFlag = ""
$configFilePath = $null

# Prefer a GitHub-specific config if present, fall back to the repo-wide NuGet.Config
$nugetGitHubConfigPath = Join-Path $SourcesDirectory "NuGet-GitHub.Config"
if (Test-Path $nugetGitHubConfigPath) {
$configSourceFlag = "--configfile `"$nugetGitHubConfigPath`""
$configFilePath = $nugetGitHubConfigPath
if ($EnableVerboseLogging) {
Write-Host " [VERBOSE] Using NuGet-GitHub.Config from: $nugetGitHubConfigPath"
}
}
else {
$nugetConfigPath = Join-Path $SourcesDirectory "NuGet.Config"
if (Test-Path $nugetConfigPath) {
$configSourceFlag = "--configfile `"$nugetConfigPath`""
$configFilePath = $nugetConfigPath
if ($EnableVerboseLogging) {
Write-Host " [VERBOSE] Using NuGet.Config from: $nugetConfigPath"
}
Expand All @@ -292,18 +290,25 @@ function Get-LatestPackageVersion {
Write-Warning "NuGet-GitHub.Config or NuGet.Config not found under: $SourcesDirectory - search may not find private feeds"
}
}

$searchCmd = "dotnet package search `"$PackageId`" --exact-match --format json $prereleaseFlag $configSourceFlag"


$dotnetArgs = @(
'package'
'search'
$PackageId
'--prerelease'
'--exact-match'
'--format'
'json'
)

if ($IncludePrerelease) {
$dotnetArgs += '--prerelease'
}

if ($configFilePath) {
$dotnetArgs += '--configfile'
$dotnetArgs += $configFilePath
}

if ($EnableVerboseLogging) {
Write-Host " [VERBOSE] Executing: dotnet $($dotnetArgs -join ' ')"
}
Expand Down