11@ echo off
22
3+ setlocal enabledelayedexpansion
4+
35set starttime = %time%
46
7+ :: Set the parameters ----------------------------------------------------------
8+
9+ REM Application
10+ set " AppName = CodeProject.AI Server"
11+ :: set "AppVersion=2.7.0" - we get this from the server's version file
12+
513REM The location of the root of the server repo relative to this script
614set repo_base = ..\..\..\CodeProject.AI-Server-Dev
715
8- :: make sure that the code is up to date
9- echo .
10- echo ---------------------------------------------------------------------------
11- echo Rebuilding the solution ...
12- echo ---------------------------------------------------------------------------
16+ REM System info
17+ set os = win
18+ set architecture = %PROCESSOR_ARCHITECTURE%
19+ if /i " !architecture! " == " arm64" (
20+ set architecture = arm64
21+ ) else (
22+ set architecture = x64
23+ )
24+
25+ REM Libraries and tools
26+ set " DotNetVersion = 8.0"
27+ set " DotNetHostingVersion = 8.0.6"
1328
14- :: go to ParseJSON utility and build
15- echo Building ParseJSON utility
29+ REM File names
30+ set " SetupScriptTemplate = installer-template.iss"
31+ set " SetupScriptOutput = installer.iss"
32+ set " SetupExeName = !AppName! -!os! -!architecture! "
33+
34+ REM Note the hosting bundle is architecture agnostic. (arm64, x64 same file)
35+ set " HostingBundleInstallerExe = dotnet-hosting-!DotNetHostingVersion! -win.exe"
36+ set " HostingBundleDownloadURL = https://download.visualstudio.microsoft.com/download/pr/751d3fcd-72db-4da2-b8d0-709c19442225/33cc492bde704bfd6d70a2b9109005a0/!HostingBundleInstallerExe! "
37+ set " HostingBundleSHA256 = 2ac38c2aab8a55e50a2d761fead1320047d2ad5fd22c2f44316aceb094505ec2"
38+
39+ set " VCRedistInstallerExe = vc_redist.x64.exe"
40+ set " VCRedistDownloadURL = https://aka.ms/vs/17/release/vc_redist.!architecture! .exe"
41+ set " VCRedistSHA256 = "
42+
43+
44+ :: Make sure that the code is up to date ---------------------------------------
45+
46+ :: Go to ParseJSON utility and build
47+ echo Building ParseJSON utility...
1648pushd %repo_base% \utils\ParseJSON
1749dotnet build -c Release --no-incremental --force
1850popd
1951
20- :: go to the server and build
21-
52+ :: Go to the server and build
53+ echo Building CodeProject.AI Server...
2254pushd %repo_base% \src\server
2355dotnet build -c Release --no-incremental --force
2456popd
2557
58+ :: Prepare the setup script
59+
60+ :: Get Version: We're building for the current server version
61+ echo Getting server version...
62+
63+ for /f " usebackq tokens=2 delims=:," %%a in (`findstr /I /R /C:" \" Major\" [^^{]*$" " !repo_base! \src\server\version.json" `) do (
64+ set " major = %%a "
65+ set major = !major:" =!
66+ set major = !major: =!
67+ )
68+ for /f " usebackq tokens=2 delims=:," %%a in (`findstr /I /R /C:" \" Minor\" [^^{]*$" " !repo_base! \src\server\version.json" `) do (
69+ set " minor = %%a "
70+ set minor = !minor:" =!
71+ set minor = !minor: =!
72+ )
73+ for /f " usebackq tokens=2 delims=:," %%a in (`findstr /I /R /C:" \" Patch\" [^^{]*$" " !repo_base! \src\server\version.json" `) do (
74+ set " patch = %%a "
75+ set patch = !patch:" =!
76+ set patch = !patch: =!
77+ )
78+ set AppVersion = !major! .!minor! .!patch!
79+
80+
81+ echo Building installer script...
82+
83+ rem Read the input file and create the output file
84+ if exist " %SetupScriptOutput% " del " %SetupScriptOutput% "
85+ for /f " tokens=* delims=" %%a in ('findstr /n " ^" " %SetupScriptTemplate% " ') do (
86+ set " line = %%a "
87+ REM echo RAW : !line!
88+
89+ set " line = !line:__PRODUCT__ =%AppName% ! "
90+ set " line = !line:__VERSION__ =%AppVersion% ! "
91+ set " line = !line:__ARCHITECTURE__ =%architecture% ! "
92+ set " line = !line:__DOTNET_VERSION__ =%DotNetVersion% ! "
93+ set " line = !line:__DOTNET_HOSTING_VERSION__ =%DotNetHostingVersion% ! "
94+ set " line = !line:__SETUP_EXE_NAME__ =%SetupExeName% ! "
95+ set " line = !line:__REPO_BASE_PATH__ =%repo_base% ! "
96+ set " line = !line:__HOSTING_BUNDLE_URL__ =%HostingBundleDownloadURL% ! "
97+ set " line = !line:__HOSTING_BUNDLE_SHA256__ =%HostingBundleSHA256% ! "
98+
99+ REM Remove line number
100+ set " line = !line:*: =! "
101+ REM echo CLEAN: !line!
102+
103+ if not defined line (
104+ echo . >> " %SetupScriptOutput% "
105+ ) else if " !line! " == " " (
106+ echo . >> " %SetupScriptOutput% "
107+ ) else (
108+ echo !line! >> " %SetupScriptOutput% "
109+ )
110+ )
111+
26112:: Run the Inno Setup compiler
27- echo .
28- echo ---------------------------------------------------------------------------
29- echo Compiling the ISS script
30- echo ---------------------------------------------------------------------------
31- " C:\Program Files (x86)\Inno Setup 6\ISCC.exe" script.iss
113+ echo Compiling the installer script...
114+ " C:\Program Files (x86)\Inno Setup 6\ISCC.exe" %SetupScriptOutput%
32115
33- echo .
34116echo ---------------------------------------------------------------------------
35- echo Don't forget to sign the exe and create a zip before pushing to AWS
117+ echo DONE! Don't forget to sign the exe and create a zip before pushing to AWS
36118echo ---------------------------------------------------------------------------
119+
37120set stoptime = %time%
38121echo Started at %starttime% . Finished at %stoptime%
0 commit comments