@@ -9,12 +9,58 @@ parameters:
99steps :
1010- powershell : |
1111 Push-Location $(IdWebSourceDir)
12- $nugetSourceIsExternal = (dotnet nuget list source --format Short).Contains("https://api.nuget.org/v3/index.json")
12+
13+ # Check if nuget.config exists
14+ $nugetConfigPath = "$(IdWebSourceDir)\nuget.config"
15+ if (Test-Path $nugetConfigPath) {
16+ Write-Host "Found nuget.config at $nugetConfigPath"
17+ } else {
18+ Write-Host "Warning: nuget.config file not found at expected path."
19+ $nugetConfigPath = "" # Use default global config
20+ }
21+
22+ Write-Host "Listing existing NuGet sources..."
23+ dotnet nuget list source
24+
25+ Write-Host "Checking if the external NuGet source exists..."
26+ $nugetSources = dotnet nuget list source --format Short
27+ $nugetSourceIsExternal = $nugetSources -match "https://api.nuget.org/v3/index.json"
28+
1329 if ($nugetSourceIsExternal) {
14- dotnet nuget remove source NuGet
30+ Write-Host "Removing external NuGet source..."
31+ if ($nugetConfigPath -ne "") {
32+ dotnet nuget remove source NuGet --configfile $nugetConfigPath
33+ } else {
34+ dotnet nuget remove source NuGet
35+ }
36+
37+ if ($?) {
38+ Write-Host "Successfully removed external NuGet source."
39+ } else {
40+ Write-Host "Failed to remove external NuGet source."
41+ exit 1
42+ }
43+ } else {
44+ Write-Host "External NuGet source not found. Skipping removal."
45+ }
46+
47+ Write-Host "Adding IDDP NuGet source..."
48+ if ($nugetConfigPath -ne "") {
49+ dotnet nuget add source https://identitydivision.pkgs.visualstudio.com/_packaging/IDDP/nuget/v3/index.json -n IDDP --configfile $nugetConfigPath
50+ } else {
1551 dotnet nuget add source https://identitydivision.pkgs.visualstudio.com/_packaging/IDDP/nuget/v3/index.json -n IDDP
16- dotnet nuget list source
1752 }
53+
54+ if ($?) {
55+ Write-Host "Successfully added IDDP NuGet source."
56+ } else {
57+ Write-Host "Failed to add IDDP NuGet source."
58+ exit 1
59+ }
60+
61+ Write-Host "Final NuGet sources list:"
62+ dotnet nuget list source
63+
1864 Pop-Location
1965 displayName : ' Remove external "NuGet" Source and add "IDDP artifacts" as a NuGet Source, if needed.'
2066
0 commit comments