Update NuGet source config and add packageSourceMapping
Renamed the private NuGet source from 'GitLab' to 'Nuget-GitLab-AIFotoONLUS' in CI scripts for clarity and consistency. Added a repository-level NuGet.Config with packageSourceMapping to ensure only specific private packages are restored from the GitLab feed, preventing 401 errors when restoring public packages from nuget.org.
This commit is contained in:
parent
38cf61ab33
commit
e556d74fd1
2 changed files with 36 additions and 6 deletions
|
|
@ -47,9 +47,9 @@ build_windows:
|
||||||
# Configure private NuGet source from GitLab Packages if credentials are provided
|
# Configure private NuGet source from GitLab Packages if credentials are provided
|
||||||
$nugetUrl = 'https://gitlab.com/api/v4/projects/79509532/packages/nuget/index.json'
|
$nugetUrl = 'https://gitlab.com/api/v4/projects/79509532/packages/nuget/index.json'
|
||||||
if ($env:NUGET_USERNAME -and $env:NUGET_PASSWORD) {
|
if ($env:NUGET_USERNAME -and $env:NUGET_PASSWORD) {
|
||||||
Write-Host 'Configuring private NuGet source GitLab...'
|
Write-Host 'Configuring private NuGet source Nuget-GitLab-AIFotoONLUS...'
|
||||||
try { & $dotnetExe nuget remove source GitLab } catch {}
|
try { & $dotnetExe nuget remove source Nuget-GitLab-AIFotoONLUS } catch {}
|
||||||
& $dotnetExe nuget add source $nugetUrl --name GitLab --username $env:NUGET_USERNAME --password $env:NUGET_PASSWORD --store-password-in-clear-text
|
& $dotnetExe nuget add source $nugetUrl --name Nuget-GitLab-AIFotoONLUS --username $env:NUGET_USERNAME --password $env:NUGET_PASSWORD --store-password-in-clear-text
|
||||||
} else {
|
} else {
|
||||||
Write-Host 'NUGET_USERNAME/NUGET_PASSWORD not set; skipping private NuGet source configuration.'
|
Write-Host 'NUGET_USERNAME/NUGET_PASSWORD not set; skipping private NuGet source configuration.'
|
||||||
}
|
}
|
||||||
|
|
@ -90,9 +90,9 @@ publish_release:
|
||||||
# Configure private NuGet source from GitLab Packages if credentials are provided
|
# Configure private NuGet source from GitLab Packages if credentials are provided
|
||||||
$nugetUrl = 'https://gitlab.com/api/v4/projects/79509532/packages/nuget/index.json'
|
$nugetUrl = 'https://gitlab.com/api/v4/projects/79509532/packages/nuget/index.json'
|
||||||
if ($env:NUGET_USERNAME -and $env:NUGET_PASSWORD) {
|
if ($env:NUGET_USERNAME -and $env:NUGET_PASSWORD) {
|
||||||
Write-Host 'Configuring private NuGet source GitLab...'
|
Write-Host 'Configuring private NuGet source Nuget-GitLab-AIFotoONLUS...'
|
||||||
try { & $dotnetExe nuget remove source GitLab } catch {}
|
try { & $dotnetExe nuget remove source Nuget-GitLab-AIFotoONLUS } catch {}
|
||||||
& $dotnetExe nuget add source $nugetUrl --name GitLab --username $env:NUGET_USERNAME --password $env:NUGET_PASSWORD --store-password-in-clear-text
|
& $dotnetExe nuget add source $nugetUrl --name Nuget-GitLab-AIFotoONLUS --username $env:NUGET_USERNAME --password $env:NUGET_PASSWORD --store-password-in-clear-text
|
||||||
} else {
|
} else {
|
||||||
Write-Host 'NUGET_USERNAME/NUGET_PASSWORD not set; skipping private NuGet source configuration.'
|
Write-Host 'NUGET_USERNAME/NUGET_PASSWORD not set; skipping private NuGet source configuration.'
|
||||||
}
|
}
|
||||||
|
|
|
||||||
30
NuGet.Config
Normal file
30
NuGet.Config
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Repository-level NuGet.Config to control which sources are queried for which
|
||||||
|
packages. This prevents the GitLab feed from being queried for all package
|
||||||
|
IDs (which causes 401 errors for packages hosted on nuget.org).
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
- Keep this file in the repository root so `dotnet restore` picks it up by default.
|
||||||
|
- CI still needs to add the `GitLab` source credentials at runtime (we do this
|
||||||
|
from the pipeline using `dotnet nuget add source ...`), but the mapping below
|
||||||
|
ensures only the listed package ID patterns are requested from the GitLab feed.
|
||||||
|
-->
|
||||||
|
<configuration>
|
||||||
|
<packageSources>
|
||||||
|
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
|
||||||
|
<add key="Nuget-GitLab-AIFotoONLUS" value="https://gitlab.com/api/v4/projects/79509532/packages/nuget/index.json" />
|
||||||
|
</packageSources>
|
||||||
|
|
||||||
|
<!-- Map private package IDs to the GitLab source; everything else uses nuget.org -->
|
||||||
|
<packageSourceMapping>
|
||||||
|
<packageSource key="Nuget-GitLab-AIFotoONLUS">
|
||||||
|
<!-- Add patterns for your private packages hosted in GitLab -->
|
||||||
|
<package pattern="AIFotoONLUS.*" />
|
||||||
|
<package pattern="AIFotoONLUS.Core" />
|
||||||
|
</packageSource>
|
||||||
|
<packageSource key="nuget.org">
|
||||||
|
<package pattern="*" />
|
||||||
|
</packageSource>
|
||||||
|
</packageSourceMapping>
|
||||||
|
</configuration>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue