Last active
December 10, 2020 22:46
-
-
Save therightstuff/79847197377062c8b2ff22b20defa165 to your computer and use it in GitHub Desktop.
Batch / bulk upload script for NuGet private repo hosted on Nexus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# to be run with git-bash on a Windows machine | |
# based on https://github.com/sonatype-nexus-community/nexus-repository-import-scripts/blob/master/nugetimport.sh | |
# download latest version of nuget.exe for Windows x86 Commandline | |
# from https://www.nuget.org/downloads into the current directory | |
# retrieve NuGet API Key from Nexus by clicking on your profile, | |
# the side bar menu should show "NuGet API Key" | |
show_usage() { | |
echo "Usage:" | |
echo "$0 -r NUGET_REPOSITORY -k NEXUS_API_KEY" | |
echo | |
echo "NUGET_REPOSITORY must be in the form https://example.com/nexus/repository/nuget-hosted" | |
echo "IMPORTANT: download the latest version of nuget.exe command line from https://www.nuget.org/downloads into the current directory" | |
echo "You can retrieve NuGet API Key from Nexus by clicking on your profile, the side bar menu should show 'NuGet API Key'" | |
} | |
if [ $# -ne 4 ]; then | |
show_usage | |
exit 1 | |
fi | |
# Get command line params | |
while getopts ":r:k:" opt; do | |
case $opt in | |
r) REPO_URL="$OPTARG" | |
;; | |
k) APIKEY="$OPTARG" | |
;; | |
h) show_usage | |
exit 0 | |
;; | |
esac | |
done | |
# find all .nupkg files in current directory and any subdirectories | |
find . -type f -not -path '*/\.*' -name '*.nupkg' -exec ./nuget.exe push {} $APIKEY -Source $REPO_URL \; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment