dotnet 跨平台编译发布

dotnet publish 命令,bash脚本如下(Windows安装git即可建议sh关联)

publish.sh

#!/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

 

 

posted @ 2019-05-25 10:06  Bob-wei  阅读(892)  评论(0编辑  收藏  举报