fix(windows): switch to system-wide VC++ redistributable, purge legacy app-local CRT DLLs, and harden documentation viewer
This commit is contained in:
1 parent
f5838f09b5
commit
ced3aa1f09
4 files changed
+39
-71
No files matched your search
@@ -336,66 +336,10 @@ jobs:
|
|||||||
throw "Flutter Windows build failed."
|
throw "Flutter Windows build failed."
|
||||||
}
|
}
|
||||||
|
|
||||||
# ------------------------------------------------------------
|
|
||||||
# Bundle Microsoft Visual C++ CRT Runtime DLLs
|
|
||||||
# Fixes: vcruntime140.dll, vcruntime140_1.dll, msvcp140.dll missing errors
|
|
||||||
# ------------------------------------------------------------
|
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "Locating Microsoft Visual C++ CRT x64 redistributable libraries..."
|
Write-Host "Verifying compiled Windows release binaries and plugin DLLs:"
|
||||||
$releaseDir = "build\windows\x64\runner\Release"
|
$releaseDir = "build\windows\x64\runner\Release"
|
||||||
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
|
Get-ChildItem -Path "$releaseDir\*.dll" | Select-Object Name, Length
|
||||||
$copied = $false
|
|
||||||
|
|
||||||
if (Test-Path $vswhere) {
|
|
||||||
$vsPath = & $vswhere -latest -products * -property installationPath
|
|
||||||
if ($vsPath -and (Test-Path "$vsPath\VC\Redist\MSVC")) {
|
|
||||||
$crtDirs = Get-ChildItem -Path "$vsPath\VC\Redist\MSVC" -Recurse -Filter "Microsoft.VC*.CRT" |
|
|
||||||
Where-Object { $_.FullName -like "*\x64\*" -and $_.FullName -notlike "*debug*" -and $_.FullName -notlike "*onecore*" }
|
|
||||||
$targetCrtDir = $crtDirs | Select-Object -First 1
|
|
||||||
if ($targetCrtDir) {
|
|
||||||
Write-Host "Found CRT DLL directory at: $($targetCrtDir.FullName)"
|
|
||||||
Copy-Item -Path "$($targetCrtDir.FullName)\*.dll" -Destination $releaseDir -Force
|
|
||||||
$copied = $true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (-not $copied) {
|
|
||||||
Write-Warning "CRT directory not found via vswhere. Searching System32 for required VC runtime DLLs..."
|
|
||||||
$requiredDlls = @(
|
|
||||||
"vcruntime140.dll",
|
|
||||||
"vcruntime140_1.dll",
|
|
||||||
"msvcp140.dll",
|
|
||||||
"msvcp140_1.dll",
|
|
||||||
"msvcp140_2.dll",
|
|
||||||
"msvcp140_atomic_wait.dll",
|
|
||||||
"msvcp140_codecvt_ids.dll",
|
|
||||||
"vcruntime140_threads.dll",
|
|
||||||
"concrt140.dll",
|
|
||||||
"vccorlib140.dll"
|
|
||||||
)
|
|
||||||
foreach ($dll in $requiredDlls) {
|
|
||||||
$sysPath = "$env:SystemRoot\System32\$dll"
|
|
||||||
if (Test-Path $sysPath) {
|
|
||||||
Copy-Item -Path $sysPath -Destination $releaseDir -Force
|
|
||||||
Write-Host "Copied $dll from System32"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$criticalDlls = @("vcruntime140.dll", "vcruntime140_1.dll", "msvcp140.dll")
|
|
||||||
foreach ($dll in $criticalDlls) {
|
|
||||||
$targetPath = Join-Path $releaseDir $dll
|
|
||||||
if (-not (Test-Path $targetPath)) {
|
|
||||||
Write-Warning "Missing critical CRT DLL: $dll in $releaseDir"
|
|
||||||
} else {
|
|
||||||
Write-Host "Verified bundled: $dll"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Host ""
|
|
||||||
Write-Host "All DLLs bundled into Windows release:"
|
|
||||||
Get-ChildItem -Path "$releaseDir\*.dll" | Select-Object Name
|
|
||||||
|
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
# Windows Installer
|
# Windows Installer
|
||||||
|
|||||||
+3
-4
@@ -49,7 +49,7 @@ flutter build apk --release --obfuscate --split-debug-info=build/app/outputs/sym
|
|||||||
The Windows client runs natively on Windows 10 and Windows 11 (64-bit).
|
The Windows client runs natively on Windows 10 and Windows 11 (64-bit).
|
||||||
|
|
||||||
### Prerequisites:
|
### Prerequisites:
|
||||||
- **Microsoft Visual C++ 2015–2022 Redistributable (x64)** (Core runtime libraries `vcruntime140_1.dll`, `msvcp140.dll`, etc. are bundled directly with the release binaries; the installer also automatically installs the full redistributable if missing).
|
- **Microsoft Visual C++ 2015–2022 Redistributable (x64)** (v14.30+ / VS 2022 toolset; the installer automatically checks system compatibility and installs the official Microsoft redistributable silently if missing or outdated).
|
||||||
- **Microsoft .NET Desktop Runtime 6.0/8.0+ (x64)** (automatically detected and installed silently by setup if missing).
|
- **Microsoft .NET Desktop Runtime 6.0/8.0+ (x64)** (automatically detected and installed silently by setup if missing).
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -73,12 +73,11 @@ flutter build windows --release --obfuscate --split-debug-info=build/windows/sym
|
|||||||
|
|
||||||
### B. Compiling the Windows Inno Setup Installer (`TIS_RMS_Client.iss`)
|
### B. Compiling the Windows Inno Setup Installer (`TIS_RMS_Client.iss`)
|
||||||
|
|
||||||
The installer script [`frontend/TIS_RMS_Client.iss`](file:///d:/Capstone/TIS_RIS_Server_Manager/TIS_RMS/frontend/TIS_RMS_Client.iss) packages the app into an ultra-compact standalone setup file (`TIS_RMS_Client_Setup_v<version>.exe` ~**16.7 MB**).
|
The installer script [`frontend/TIS_RMS_Client.iss`](file:///f:/SumbrerongBato/tis_rms_server/frontend/TIS_RMS_Client.iss) packages the app into an ultra-compact standalone setup file (`TIS_RMS_Client_Setup_v<version>.exe` ~**16.7 MB**).
|
||||||
|
|
||||||
#### Features:
|
#### Features:
|
||||||
- **Small File Size (~17 MB)**: Uses `lzma2/ultra64` solid 64MB dictionary compression.
|
- **Small File Size (~17 MB)**: Uses `lzma2/ultra64` solid 64MB dictionary compression.
|
||||||
- **Bundled VC++ Runtime DLLs**: Packages MSVC CRT libraries (`vcruntime140.dll`, `vcruntime140_1.dll`, `msvcp140.dll`, etc.) directly into the application folder to prevent missing DLL crashes.
|
- **Automated System-Wide VC++ & .NET Runtime Setup**: Automatically detects whether a compatible Visual Studio 2022 (v14.30+) x64 runtime is installed in Windows (`System32`) and silently installs Microsoft's official `vc_redist.x64.exe` if missing or outdated. Also purges legacy app-local CRT DLLs to prevent ABI mismatch crashes.
|
||||||
- **Automated VC++ & .NET Runtime Setup**: Checks system registry and automatically installs Microsoft Visual C++ 2015-2022 Redistributable and Microsoft .NET Desktop Runtime silently if missing.
|
|
||||||
- **Selectable Destination Path**: Lets the user choose where to install (defaults to `C:\Program Files\TIS RMS Client`).
|
- **Selectable Destination Path**: Lets the user choose where to install (defaults to `C:\Program Files\TIS RMS Client`).
|
||||||
- **Desktop Shortcut Checkbox**: Optional checkbox on the tasks page to create a desktop shortcut with the official school icon logo.
|
- **Desktop Shortcut Checkbox**: Optional checkbox on the tasks page to create a desktop shortcut with the official school icon logo.
|
||||||
- **Start Menu & Uninstaller**: Registers a Start Menu program group and includes a clean uninstaller in Windows *Apps & Features* / *Settings*.
|
- **Start Menu & Uninstaller**: Registers a Start Menu program group and includes a clean uninstaller in Windows *Apps & Features* / *Settings*.
|
||||||
|
|||||||
@@ -58,12 +58,19 @@ Name: "english"; MessagesFile: "compiler:Default.isl"
|
|||||||
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
|
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
|
||||||
|
|
||||||
[Files]
|
[Files]
|
||||||
; Main application binaries and libraries (excludes unnecessary dev .lib and .exp files for smaller footprint)
|
; Main application binaries and libraries (excludes unnecessary dev .lib/.exp and prevents app-local CRT poisoning)
|
||||||
Source: "build\windows\x64\runner\Release\*.exe"; DestDir: "{app}"; Flags: ignoreversion
|
Source: "build\windows\x64\runner\Release\*.exe"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
Source: "build\windows\x64\runner\Release\*.dll"; DestDir: "{app}"; Flags: ignoreversion
|
Source: "build\windows\x64\runner\Release\*.dll"; DestDir: "{app}"; Flags: ignoreversion; Excludes: "msvcp140*.dll,vcruntime140*.dll,concrt140.dll,vccorlib140.dll"
|
||||||
Source: "build\windows\x64\runner\Release\data\*"; DestDir: "{app}\data"; Flags: ignoreversion recursesubdirs createallsubdirs
|
Source: "build\windows\x64\runner\Release\data\*"; DestDir: "{app}\data"; Flags: ignoreversion recursesubdirs createallsubdirs
|
||||||
Source: "{#MyAppIcon}"; DestDir: "{app}"; DestName: "app_icon.ico"; Flags: ignoreversion
|
Source: "{#MyAppIcon}"; DestDir: "{app}"; DestName: "app_icon.ico"; Flags: ignoreversion
|
||||||
|
|
||||||
|
[InstallDelete]
|
||||||
|
; Clean up any legacy app-local MSVC CRT DLLs from older installations so app always uses C:\Windows\System32
|
||||||
|
Type: files; Name: "{app}\msvcp140*.dll"
|
||||||
|
Type: files; Name: "{app}\vcruntime140*.dll"
|
||||||
|
Type: files; Name: "{app}\concrt140.dll"
|
||||||
|
Type: files; Name: "{app}\vccorlib140.dll"
|
||||||
|
|
||||||
[Icons]
|
[Icons]
|
||||||
; Start menu shortcut
|
; Start menu shortcut
|
||||||
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\app_icon.ico"
|
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\app_icon.ico"
|
||||||
@@ -77,14 +84,30 @@ Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilen
|
|||||||
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
|
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
|
||||||
|
|
||||||
[Code]
|
[Code]
|
||||||
// Helper function to verify Microsoft Visual C++ 2015-2022 Redistributable (x64)
|
// Helper function to verify Microsoft Visual C++ 2015-2022 Redistributable (x64, Minor >= 30 for VS 2022 compatibility)
|
||||||
function IsVCRedistInstalled: Boolean;
|
function IsVCRedistCompatible: Boolean;
|
||||||
var
|
var
|
||||||
installed: Cardinal;
|
installed: Cardinal;
|
||||||
|
minor: Cardinal;
|
||||||
begin
|
begin
|
||||||
Result := RegQueryDWordValue(HKLM64, 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\X64', 'Installed', installed) and (installed = 1);
|
Result := False;
|
||||||
|
if RegQueryDWordValue(HKLM64, 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\X64', 'Installed', installed) and (installed = 1) then
|
||||||
|
begin
|
||||||
|
if RegQueryDWordValue(HKLM64, 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\X64', 'Minor', minor) then
|
||||||
|
Result := (minor >= 30) // Minor 30+ indicates Visual Studio 2022 or newer
|
||||||
|
else
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
if not Result then
|
if not Result then
|
||||||
Result := RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\X64', 'Installed', installed) and (installed = 1);
|
begin
|
||||||
|
if RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\X64', 'Installed', installed) and (installed = 1) then
|
||||||
|
begin
|
||||||
|
if RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\X64', 'Minor', minor) then
|
||||||
|
Result := (minor >= 30)
|
||||||
|
else
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Helper function to verify Microsoft .NET Desktop Runtime
|
// Helper function to verify Microsoft .NET Desktop Runtime
|
||||||
@@ -101,8 +124,8 @@ var
|
|||||||
begin
|
begin
|
||||||
if CurStep = ssPostInstall then
|
if CurStep = ssPostInstall then
|
||||||
begin
|
begin
|
||||||
// If Microsoft Visual C++ 2015-2022 Redistributable (x64) is not installed, automatically install it silently
|
// If Microsoft Visual C++ 2015-2022 Redistributable (x64) is not installed or outdated (< VS 2022), automatically install it silently
|
||||||
if not IsVCRedistInstalled then
|
if not IsVCRedistCompatible then
|
||||||
begin
|
begin
|
||||||
Exec('powershell.exe', '-NoProfile -ExecutionPolicy Bypass -Command "$ProgressPreference = ''SilentlyContinue''; try { if (Get-Command winget -ErrorAction SilentlyContinue) { winget install --id Microsoft.VCRedist.2015+.x64 --silent --accept-package-agreements --accept-source-agreements } else { $url = ''https://aka.ms/vs/17/release/vc_redist.x64.exe''; $out = ''$env:TEMP\vc_redist.x64.exe''; Invoke-WebRequest -Uri $url -OutFile $out; Start-Process -FilePath $out -ArgumentList ''/install /quiet /norestart'' -Wait } } catch {}"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
|
Exec('powershell.exe', '-NoProfile -ExecutionPolicy Bypass -Command "$ProgressPreference = ''SilentlyContinue''; try { if (Get-Command winget -ErrorAction SilentlyContinue) { winget install --id Microsoft.VCRedist.2015+.x64 --silent --accept-package-agreements --accept-source-agreements } else { $url = ''https://aka.ms/vs/17/release/vc_redist.x64.exe''; $out = ''$env:TEMP\vc_redist.x64.exe''; Invoke-WebRequest -Uri $url -OutFile $out; Start-Process -FilePath $out -ArgumentList ''/install /quiet /norestart'' -Wait } } catch {}"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
|
||||||
end;
|
end;
|
||||||
|
|||||||
@@ -339,7 +339,9 @@ class _WindowsDocViewState extends State<_WindowsDocView> {
|
|||||||
|
|
||||||
if (_isInitialized) {
|
if (_isInitialized) {
|
||||||
try {
|
try {
|
||||||
_controller.dispose();
|
_controller.dispose().catchError((e) {
|
||||||
|
debugPrint('[DocumentationScreen] webview async dispose error: $e');
|
||||||
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugPrint('[DocumentationScreen] webview dispose error: $e');
|
debugPrint('[DocumentationScreen] webview dispose error: $e');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user