Skip to content

Commit a60a8ee

Browse files
committed
Dynamically building Inno script to allow arm64 installer
1 parent 7e623ce commit a60a8ee

4 files changed

Lines changed: 1219 additions & 23 deletions

File tree

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#define SetupExeName "CodeProject.AI-Server-win-x64"
99

1010
#define ServerRepoRelPath "..\..\..\CodeProject.AI-Server-Dev"
11+
1112
#define AppExe "Server\CodeProject.AI.Server.exe"
1213
#define GettingStartedURL "https://www.codeproject.com/Articles/5322557/CodeProject-AI-Server-AI-the-easy-way"
1314
#define DocumentationURL "https://www.codeproject.com/AI/docs/"
@@ -19,17 +20,13 @@
1920

2021
#define HostingBundleInstallerExe "dotnet-hosting-8.0.6-win.exe"
2122
#define HostingBundleDownloadURL "https://download.visualstudio.microsoft.com/download/pr/751d3fcd-72db-4da2-b8d0-709c19442225/33cc492bde704bfd6d70a2b9109005a0/dotnet-hosting-8.0.6-win.exe"
22-
;*** REVIEW: [Matthew] THIS NEEDS TO BE UPDATED ***
23-
;#define HostingBundleSHA256 "70f69a7f9a2f97bb8769559b74caad14570cd3fe4f16c1633f87ef3f2adb6db6"
2423
#define HostingBundleSHA256 "2ac38c2aab8a55e50a2d761fead1320047d2ad5fd22c2f44316aceb094505ec2"
25-
;*** REVIEW: [Matthew] Or we can use this SHA512 (which is up to date for version 8.0.6)
26-
;#define HostingBundleSHA512 "01c4d06e0bb10e69581b67fba6618f003fdbdd6043bab4c58c47b7f8ac25e52ab7bd3e39404f733821fe6083e2462dbca20b2ff948a7abe8fbb4fd2f26956584"
2724

2825
#define VCRedistInstallerExe "vc_redist.x64.exe"
29-
;Latest version. Hash will change when version changes
30-
;This insures we are getting the current security and bug fixes.
31-
;An empty SHA256 string disables the hash check
26+
; Latest version. Hash will change when version changes this insures we are getting the current
27+
; security and bug fixes.
3228
#define VCRedistDownloadURL "https://aka.ms/vs/17/release/vc_redist.x64.exe"
29+
;An empty SHA256 string disables the hash check
3330
#define VCRedistSHA256 ""
3431

3532
;Use a specific version URL and hash if you want to ensure file integrity, but it is a MS download site.

Windows/Inno Setup/build_inno.bat

Lines changed: 99 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,121 @@
11
@echo off
22

3+
setlocal enabledelayedexpansion
4+
35
set 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+
513
REM The location of the root of the server repo relative to this script
614
set 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...
1648
pushd %repo_base%\utils\ParseJSON
1749
dotnet build -c Release --no-incremental --force
1850
popd
1951

20-
:: go to the server and build
21-
52+
:: Go to the server and build
53+
echo Building CodeProject.AI Server...
2254
pushd %repo_base%\src\server
2355
dotnet build -c Release --no-incremental --force
2456
popd
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.
34116
echo ---------------------------------------------------------------------------
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
36118
echo ---------------------------------------------------------------------------
119+
37120
set stoptime=%time%
38121
echo Started at %starttime%. Finished at %stoptime%

0 commit comments

Comments
 (0)