@@ -167,9 +167,13 @@ jobs:
167167
168168 foreach ($packageRef in $packageRefs) {
169169 $packageName = $packageRef.Include
170- Write-Host " Updating $packageName..."
170+ $currentVersion = $packageRef.Version
171+ Write-Host " Updating $packageName (current: $currentVersion)..."
171172 try {
172- dotnet add "$csprojPath" package $packageName --source $sourceUrl 2>&1 | Out-Null
173+ # Remove then re-add to force update
174+ dotnet remove "$csprojPath" package $packageName 2>&1 | Out-Null
175+ $addOutput = dotnet add "$csprojPath" package $packageName --source $sourceUrl 2>&1
176+ Write-Host " $addOutput"
173177 if ($LASTEXITCODE -eq 0) {
174178 Write-Host " Updated $packageName" -ForegroundColor Green
175179 }
@@ -220,35 +224,28 @@ jobs:
220224 $shouldBuild = $true
221225
222226 try {
223- $searchOutput = dotnet nuget search $packageName --source $sourceUrl --format json 2>&1
224- if ($LASTEXITCODE -eq 0 -and $searchOutput -match '^\s*\{') {
225- $nugetVersions = $searchOutput | ConvertFrom-Json
226-
227- if ($nugetVersions.searchResult -and $nugetVersions.searchResult.Count -gt 0) {
228- $existingPackage = $nugetVersions.searchResult | Where-Object { $_.packages.id -eq $packageName } | Select-Object -First 1
229- if ($existingPackage -and $existingPackage.packages -and $existingPackage.packages.Count -gt 0) {
230- $publishedVersion = $existingPackage.packages[0].version
231- Write-Host "Published version: $publishedVersion"
232-
233- if ($localVersion -eq $publishedVersion) {
234- Write-Host "Version $localVersion already published - skipping" -ForegroundColor Yellow
235- $skippedPackages += $package
236- $shouldBuild = $false
237- } elseif ([version]$localVersion -le [version]$publishedVersion) {
238- Write-Host "Local version $localVersion is not higher than published $publishedVersion - skipping" -ForegroundColor Yellow
239- $skippedPackages += $package
240- $shouldBuild = $false
241- }
242- }
243- } else {
244- Write-Host "No published version found - will build"
245- }
227+ # Try to download package metadata directly from GitHub Packages
228+ $headers = @{
229+ "Authorization" = "Bearer $env:GITHUB_TOKEN"
230+ }
231+ $packageUrl = "https://nuget.pkg.github.com/malforge/download/$packageName/$localVersion/$packageName.$localVersion.nupkg"
232+
233+ Write-Host "Checking if version $localVersion exists..."
234+ $response = Invoke-WebRequest -Uri $packageUrl -Method Head -Headers $headers -ErrorAction SilentlyContinue
235+
236+ if ($response.StatusCode -eq 200) {
237+ Write-Host "Version $localVersion already exists - skipping" -ForegroundColor Yellow
238+ $skippedPackages += $package
239+ $shouldBuild = $false
246240 } else {
247- Write-Host "Could not query NuGet feed (may not exist yet) - will build"
241+ Write-Host "Version $localVersion not found - will build"
248242 }
249243 } catch {
250- Write-Host "Could not query NuGet feed: $_" -ForegroundColor Yellow
251- Write-Host "Will build package anyway"
244+ if ($_.Exception.Response.StatusCode -eq 404) {
245+ Write-Host "Version $localVersion not found - will build"
246+ } else {
247+ Write-Host "Could not check version (error: $($_.Exception.Message)) - will build anyway"
248+ }
252249 }
253250
254251 if (-not $shouldBuild) {
0 commit comments