Updated .net actions.

This commit is contained in:
2025-07-07 20:58:04 -07:00
parent 50bfb1278e
commit d41bf186fe
11 changed files with 188 additions and 36 deletions

View File

@@ -0,0 +1,44 @@
#!/bin/bash
# Function to add or remove a single NuGet source
add_or_remove_nuget_source() {
local action="$1"
local source="$2"
local username="$3"
local password="$4"
if [[ -n "$source" ]]; then
if [[ "$action" == "remove" ]]; then
echo "Removing NuGet source: $source"
dotnet nuget remove source "$source" 2>/dev/null || true
else
echo "Adding NuGet source: $source"
if [[ -n "$username" && -n "$password" ]]; then
dotnet nuget add source "$source" --username "$username" --password "$password" --store-password-in-clear-text
else
dotnet nuget add source "$source"
fi
fi
fi
}
# Function to add/remove NuGet sources
handle_nuget_sources() {
local action="${1:-add}" # Default to 'add', can be 'remove'
if [[ -n "$NUGET_SOURCES" ]]; then
# Split sources, usernames, and passwords on newlines
IFS=$'\n' read -rd '' -a sources <<< "$NUGET_SOURCES"
IFS=$'\n' read -rd '' -a usernames <<< "$NUGET_USERNAMES"
IFS=$'\n' read -rd '' -a passwords <<< "$NUGET_PASSWORDS"
# Loop through sources
for i in "${!sources[@]}"; do
# Trim whitespace
source=$(echo "${sources[$i]}" | xargs)
username=$(echo "${usernames[$i]:-}" | xargs)
password=$(echo "${passwords[$i]:-}" | xargs)
add_or_remove_nuget_source "$action" "$source" "$username" "$password"
done
fi
}