diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8a7267c..a7ae755 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -45,16 +45,44 @@ build_windows: } # Configure private NuGet source from GitLab Packages using CI_JOB_TOKEN + # Fallback to repository variables NUGET_USERNAME/NUGET_PASSWORD for shared runners $nugetUrl = 'https://gitlab.com/api/v4/projects/79509532/packages/nuget/index.json' + $authMode = $null if ($env:CI_JOB_TOKEN) { Write-Host 'Configuring private NuGet source Nuget-GitLab-AIFotoONLUS using CI_JOB_TOKEN...' try { & $dotnetExe nuget remove source Nuget-GitLab-AIFotoONLUS } catch {} & $dotnetExe nuget add source $nugetUrl --name Nuget-GitLab-AIFotoONLUS --username gitlab-ci-token --password $env:CI_JOB_TOKEN --store-password-in-clear-text + $authMode = 'JobToken' + } elseif ($env:NUGET_USERNAME -and $env:NUGET_PASSWORD) { + Write-Host 'Configuring private NuGet source Nuget-GitLab-AIFotoONLUS using NUGET_USERNAME/NUGET_PASSWORD...' + try { & $dotnetExe nuget remove source Nuget-GitLab-AIFotoONLUS } catch {} + & $dotnetExe nuget add source $nugetUrl --name Nuget-GitLab-AIFotoONLUS --username $env:NUGET_USERNAME --password $env:NUGET_PASSWORD --store-password-in-clear-text + $authMode = 'UserCreds' } else { - Write-Host 'CI_JOB_TOKEN not available; skipping private NuGet source configuration.' + Write-Host 'No credentials available; skipping private NuGet source configuration.' } & $dotnetExe --info + # Diagnostic: verify GitLab NuGet feed and package visibility using configured auth + if ($authMode) { + Write-Host 'Checking GitLab NuGet feed index and project packages for AIFotoONLUS.Core using auth mode:' $authMode + try { + if ($authMode -eq 'JobToken') { + $headers = @{ 'JOB-TOKEN' = $env:CI_JOB_TOKEN } + } else { + $pair = "$env:NUGET_USERNAME:$env:NUGET_PASSWORD" + $b64 = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes($pair)) + $headers = @{ Authorization = "Basic $b64" } + } + Invoke-RestMethod -Uri $nugetUrl -Headers $headers -Method Get | ConvertTo-Json | Write-Host + } catch { Write-Host "Failed to fetch feed index: $_" } + try { + $pkgApi = "https://gitlab.com/api/v4/projects/79509532/packages?package_name=AIFotoONLUS.Core" + Invoke-RestMethod -Uri $pkgApi -Headers $headers -Method Get | ConvertTo-Json | Write-Host + } catch { Write-Host "Failed to query project packages API: $_" } + } else { + Write-Host 'Skipping feed diagnostics because no auth configured.' + } & $dotnetExe restore & $dotnetExe build "imagecatalog\ImageCatalog 2.csproj" -c $env:BUILD_CONFIG -v minimal } @@ -88,13 +116,18 @@ publish_release: Write-Host "Published to $(pwd)\\publish" # Configure private NuGet source from GitLab Packages using CI_JOB_TOKEN + # Fallback to repository variables NUGET_USERNAME/NUGET_PASSWORD for shared runners $nugetUrl = 'https://gitlab.com/api/v4/projects/79509532/packages/nuget/index.json' if ($env:CI_JOB_TOKEN) { Write-Host 'Configuring private NuGet source Nuget-GitLab-AIFotoONLUS using CI_JOB_TOKEN...' try { & $dotnetExe nuget remove source Nuget-GitLab-AIFotoONLUS } catch {} & $dotnetExe nuget add source $nugetUrl --name Nuget-GitLab-AIFotoONLUS --username gitlab-ci-token --password $env:CI_JOB_TOKEN --store-password-in-clear-text + } elseif ($env:NUGET_USERNAME -and $env:NUGET_PASSWORD) { + Write-Host 'Configuring private NuGet source Nuget-GitLab-AIFotoONLUS using NUGET_USERNAME/NUGET_PASSWORD...' + try { & $dotnetExe nuget remove source Nuget-GitLab-AIFotoONLUS } catch {} + & $dotnetExe nuget add source $nugetUrl --name Nuget-GitLab-AIFotoONLUS --username $env:NUGET_USERNAME --password $env:NUGET_PASSWORD --store-password-in-clear-text } else { - Write-Host 'CI_JOB_TOKEN not available; skipping private NuGet source configuration.' + Write-Host 'No credentials available; skipping private NuGet source configuration.' } # Find first file in publish folder