Repository navigation
Expand file tree
/
Copy pathbuild.bat
More file actions
150 lines (119 loc) · 2.91 KB
/
Copy pathbuild.bat
File metadata and controls
150 lines (119 loc) · 2.91 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
@echo off
set msbuildcfg=msbuild.cfg
set MSBUILD_PATH=
set havedotnet=
set havemsbuild=
set localsettings=localsettings.props
set configs=configurations.txt
set solution=OneIMExtensionExample.sln
if exist %msbuildcfg% (
for /f "usebackq delims=" %%x in (%msbuildcfg%) do (set "%%x")
)
if defined MSBUILD_PATH (
if exist %MSBUILD_PATH% (
set havemsbuild=12
set anyfound=1
)
)
where /Q dotnet.exe && (
set havedotnet=34
set anyfound=1
)
if not "%anyfound%"=="1" (
echo Neither MSBuild nor dotnet build found.
echo=
pause
exit /b 1
)
if not exist %localsettings% (
echo Error: %localsettings% does not exist. Please copy %localsettings%.template to %localsettings% and edit.
pause
exit /b 1
)
for /f "usebackq delims=" %%x in (%msbuildcfg%) do (set "%%x")
set generateconfigs=0
set seen=0
for /F "delims=" %%x in ('dir /B /O:-D /T:W %configs% %solution%') do (
setlocal enabledelayedexpansion
if !seen!==0 (
if %%x==%solution% set generateconfigs=1
set seen=1
)
)
if %generateconfigs%==1 (
if exist %configs% (
del %configs%
echo regenerating %configs%
) else (
echo File %configs% does not exist, generating
)
setlocal enabledelayedexpansion
set in_section=0
for /f "usebackq delims=" %%l in (%solution%) do (
set "line=%%l"
set do_output=0
if !in_section!==2 set in_section=1
if !in_section!==0 (
echo "!line!" | findstr /C:"GlobalSection(SolutionConfigurationPlatforms) = preSolution" > nul
if !errorlevel!==0 set in_section=2
) else (
echo "!line!" | findstr /c:"EndGlobalSection" > nul
if !errorlevel!==0 set in_section=0
)
if !in_section!==1 (
echo "!line!" | findstr /C:" = " > nul
if !errorlevel!==0 set do_output=1
)
if !do_output!==1 (
for /f "tokens=*" %%t in ("!line!") do (for /f "tokens=1 delims=|" %%x in ("%%t") do (echo %%x>>"%configs%"))
)
)
endlocal
)
set index=0
echo Available configurations:
echo ---
echo=
for /f "usebackq tokens=*" %%a in (%configs%) do (
setlocal enabledelayedexpansion
findstr /C:"'%%a'" %localsettings% >nul
if !errorlevel!==0 (
set /a index+=1
echo !index! - %%a
set CONFIG_!index!=%%a
)
)
echo=
set /p choice=Enter your desired configuration:
set CONFIG=!CONFIG_%choice%!
findstr /R /C:"^%CONFIG%$" %configs% >nul
if %errorlevel% neq 0 (
echo Configuration "%CONFIG%" not found, aborting.
pause
exit /b 1
)
REM einfach öfter mal GOTO wagen ;)
if defined havemsbuild (
if not defined havedotnet goto build_msbuild
)
if defined havedotnet (
if not defined havemsbuild goto build_dotnet
)
echo 1. dotnet
echo 2. MSBuild
choice /c 12 /m "Select build option: "
if errorlevel 2 (
goto build_msbuild
)
if errorlevel 1 (
goto build_dotnet
)
:build_msbuild
%MSBUILD_PATH% /p:Configuration=%CONFIG%
goto end
:build_dotnet
dotnet restore /p:Configuration=%CONFIG%
dotnet build -c %CONFIG%
goto end
:end
pause