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
52 changes: 49 additions & 3 deletions build/template-restore-build-MSIdentityWeb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,58 @@ parameters:
steps:
- powershell: |
Push-Location $(IdWebSourceDir)
$nugetSourceIsExternal = (dotnet nuget list source --format Short).Contains("https://api.nuget.org/v3/index.json")

# Check if nuget.config exists
$nugetConfigPath = "$(IdWebSourceDir)\nuget.config"
if (Test-Path $nugetConfigPath) {
Write-Host "Found nuget.config at $nugetConfigPath"
} else {
Write-Host "Warning: nuget.config file not found at expected path."
$nugetConfigPath = "" # Use default global config
}

Write-Host "Listing existing NuGet sources..."
dotnet nuget list source

Write-Host "Checking if the external NuGet source exists..."
$nugetSources = dotnet nuget list source --format Short
$nugetSourceIsExternal = $nugetSources -match "https://api.nuget.org/v3/index.json"

if ($nugetSourceIsExternal) {
dotnet nuget remove source NuGet
Write-Host "Removing external NuGet source..."
if ($nugetConfigPath -ne "") {
dotnet nuget remove source NuGet --configfile $nugetConfigPath
} else {
dotnet nuget remove source NuGet
}

if ($?) {
Write-Host "Successfully removed external NuGet source."
} else {
Write-Host "Failed to remove external NuGet source."
exit 1
}
} else {
Write-Host "External NuGet source not found. Skipping removal."
}

Write-Host "Adding IDDP NuGet source..."
if ($nugetConfigPath -ne "") {
dotnet nuget add source https://identitydivision.pkgs.visualstudio.com/_packaging/IDDP/nuget/v3/index.json -n IDDP --configfile $nugetConfigPath
} else {
dotnet nuget add source https://identitydivision.pkgs.visualstudio.com/_packaging/IDDP/nuget/v3/index.json -n IDDP
dotnet nuget list source
}

if ($?) {
Write-Host "Successfully added IDDP NuGet source."
} else {
Write-Host "Failed to add IDDP NuGet source."
exit 1
}

Write-Host "Final NuGet sources list:"
dotnet nuget list source

Pop-Location
displayName: 'Remove external "NuGet" Source and add "IDDP artifacts" as a NuGet Source, if needed.'

Expand Down
Loading