dotnet publish 命令,bash腳本以下(Windows安裝git便可建議sh關聯)linux
publish.shgit
#!/usr/bin/env bash # one line command: # array=( win-x64 linux-x64 osx-x64 ); for i in "${array[@]}"; do printf "\n>>> building $i ...\n\n"; dotnet publish -r $i -c Release -p:PublishSingleFile=true; done set +x +e # runtime array: https://docs.microsoft.com/en-us/dotnet/core/rid-catalog array=( win-x64 linux-x64 osx-x64 ) config='Release' # publish args: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-publish args='' declare -i count=${#array[*]} declare -i num=1 printf '>>> \033[1;36mClean bin folder ...\033[0m\n\n' find . -type d \( -iname 'bin' -o -iname 'obj' \) | xargs rm -rf printf '\033[1;36mOK\033[0m\n' for i in "${array[@]}"; do printf "\n>>> \033[1;36m($num/$count) Building $i ...\033[0m\n\n" dotnet publish -r $i -c $config -p:PublishSingleFile=true $args if [ $? = 0 ]; then printf '\n\033[1;32m'SUCCESS'\033[0m\n' else printf '\n\033[1;31m'ERROR: $?'\033[0m\n' fi let num+=1 done printf "\n\033[1;36mAll done. 10s to exit ...\033[0m\n" sleep 10s