Last active
August 29, 2015 14:18
-
-
Save Miliox/3e4eecec9f0bae5a93e5 to your computer and use it in GitHub Desktop.
Better msbuild command line interface
This file contains hidden or 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 | |
| # title : ms.sh | |
| # descriptipion : better MSBuild for command line | |
| # author : Emiliano Firmino | |
| # date : 2015-04-07 | |
| # version : 0.2 | |
| # usage : source ms.sh | |
| # notes : change $PATH_TO_MSBUILD to correct path to your msbuild installation | |
| alias msbuild=$PATH_TO_MSBUILD # change here! | |
| # straighfoward wrapper function over MSBuild to turn it usable in command line | |
| function ms() { | |
| local count_sln=`ls -1 *.sln 2>/dev/null | wc -l` | |
| if [[ $count_sln -eq 0 ]]; then | |
| echo "error: no solution in directory" | |
| return 1; | |
| fi | |
| local alias_is_set=`alias | grep msbuild | cut -d '=' -f 2 | tr -d "'"` | |
| if [[ -z $alias_is_set ]]; then | |
| echo please, set msbuild alias | |
| return 1 | |
| fi | |
| if [[ ! -z $1 ]]; then | |
| case $1 in | |
| build) local TARGET="Build" | |
| ;; | |
| clean) local TARGET="Clean" | |
| ;; | |
| rebuild) local TARGET="Rebuild" | |
| ;; | |
| *) local SHOW_USAGE="1" | |
| ;; | |
| esac | |
| else | |
| local SHOW_USAGE="1" | |
| fi | |
| if [[ ! -z $2 ]]; then | |
| case $2 in | |
| "debug") local CONFIGURATION="Debug" | |
| ;; | |
| "release") local CONFIGURATION="Release" | |
| ;; | |
| "arm") local CONFIGURATION="Debug" | |
| local PLATFORM="ARM" | |
| ;; | |
| "x64") local CONFIGURATION="Debug" | |
| local PLATFORM="x64" | |
| ;; | |
| "x86") local CONFIGURATION="Debug" | |
| local PLATFORM="x86" | |
| ;; | |
| *) local SHOW_USAGE="1" | |
| ;; | |
| esac | |
| else | |
| local CONFIGURATION="Debug" | |
| local PLATFORM="ARM" | |
| fi | |
| if [[ ! -z $3 ]]; then | |
| case $3 in | |
| "arm") local PLATFORM="ARM" | |
| ;; | |
| "x64") local PLATFORM="x64" | |
| ;; | |
| "x86") local PLATFORM="x86" | |
| ;; | |
| *) local SHOW_USAGE="1" | |
| ;; | |
| esac | |
| else | |
| if [[ ! -z $CONFIGURATION ]] && [[ -z $PLATFORM ]]; then | |
| PLATFORM="ARM" | |
| fi | |
| fi | |
| if [[ -z $SHOW_USAGE ]]; then | |
| msbuild /m /p:Configuration=${CONFIGURATION},Platform=${PLATFORM} /t:$TARGET /verbosity:minimal | |
| else | |
| echo "usage: ms build|clean|rebuild [debug*|release] [arm*|x64|x86]" | |
| fi | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment