-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·123 lines (106 loc) · 3.14 KB
/
build.sh
File metadata and controls
executable file
·123 lines (106 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/bash
# RevitPy Build Script for Linux/macOS
set -e
# Default values
CONFIGURATION="Debug"
PLATFORM="x64"
RUN_TESTS=false
CLEAN=false
RESTORE=false
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
-c|--configuration)
CONFIGURATION="$2"
shift 2
;;
-p|--platform)
PLATFORM="$2"
shift 2
;;
-t|--test)
RUN_TESTS=true
shift
;;
--clean)
CLEAN=true
shift
;;
--restore)
RESTORE=true
shift
;;
-h|--help)
echo "RevitPy Build Script"
echo ""
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " -c, --configuration Build configuration (Debug|Release) [default: Debug]"
echo " -p, --platform Target platform (x64|AnyCPU) [default: x64]"
echo " -t, --test Run tests after build"
echo " --clean Clean before build"
echo " --restore Restore packages before build"
echo " -h, --help Show this help message"
exit 0
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color
echo -e "${GREEN}RevitPy Build Script${NC}"
echo -e "${GREEN}===================${NC}"
echo -e "${YELLOW}Configuration: $CONFIGURATION${NC}"
echo -e "${YELLOW}Platform: $PLATFORM${NC}"
echo ""
# Get script directory
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
SOLUTION_FILE="$SCRIPT_DIR/RevitPy.sln"
# Clean if requested
if [ "$CLEAN" = true ]; then
echo -e "${YELLOW}Cleaning solution...${NC}"
dotnet clean "$SOLUTION_FILE" --configuration "$CONFIGURATION" --verbosity minimal
echo -e "${GREEN}Clean completed successfully${NC}"
fi
# Restore packages if requested or if this is a clean build
if [ "$RESTORE" = true ] || [ "$CLEAN" = true ]; then
echo -e "${YELLOW}Restoring NuGet packages...${NC}"
dotnet restore "$SOLUTION_FILE" --verbosity minimal
echo -e "${GREEN}Restore completed successfully${NC}"
fi
# Build the solution
echo -e "${YELLOW}Building solution...${NC}"
BUILD_ARGS=(
"build" "$SOLUTION_FILE"
"--configuration" "$CONFIGURATION"
"--no-restore"
"--verbosity" "minimal"
)
if [ "$PLATFORM" = "x64" ]; then
BUILD_ARGS+=("--arch" "x64")
fi
dotnet "${BUILD_ARGS[@]}"
echo -e "${GREEN}Build completed successfully${NC}"
# Run tests if requested
if [ "$RUN_TESTS" = true ]; then
echo -e "${YELLOW}Running tests...${NC}"
TEST_ARGS=(
"test" "$SOLUTION_FILE"
"--configuration" "$CONFIGURATION"
"--no-build"
"--verbosity" "normal"
"--logger" "console;verbosity=detailed"
)
dotnet "${TEST_ARGS[@]}"
echo -e "${GREEN}All tests passed${NC}"
fi
echo ""
echo -e "${GREEN}Build completed successfully!${NC}"
echo -e "${YELLOW}Output directory: ./src/{ProjectName}/bin/$CONFIGURATION/net6.0${NC}"