Port of dotnet/runtime#1059 to 3.1 branch (#27986)
[platform/upstream/coreclr.git] / clean.sh
1 #!/usr/bin/env bash
2
3 usage()
4 {
5     echo "Usage: clean [-b] [-p] [-c] [-all]"
6     echo "Repository cleaning script."
7     echo "  -b         Delete the binary output directory."
8     echo "  -p         Delete the repo-local NuGet package directory."
9     echo "  -c         Delete the user-local NuGet package caches."
10     echo "  -all       Cleans repository and restores it to pristine state."
11     echo
12     echo "If no option is specified, then \"clean.sh -b\" is implied."
13     exit 1
14 }
15
16 if [ "$1" == "-?" ] || [ "$1" == "-h" ]; then
17     usage
18 fi
19
20 # Implement VBCSCompiler.exe kill logic once VBCSCompiler.exe is ported to unixes
21
22 __working_tree_root="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
23
24 if [ "$*" == "-all" ]
25 then
26    echo "Removing all untracked files in the working tree"
27    git clean -xdf $__working_tree_root
28    exit $?
29 elif  [ $# == 0 ] || [ "$*" == "-b" ]; then
30     __args="/t:CleanAllProjects"
31 elif  [ "$*" == "-p" ]; then
32     __args="/t:CleanPackages"
33 elif  [ "$*" == "-c" ]; then
34     __args="/t:CleanPackagesCache"
35 fi
36
37
38 $__working_tree_root/dotnet.sh msbuild /nologo /verbosity:minimal /clp:Summary /flp:v=normal\;LogFile=clean.log $__args
39 exit $?