增强应用程序异常处理机制,新增未处理异常日志记录功能,确保在启动和运行期间捕获并记录异常信息。同时,重构配置文件加载逻辑,支持用户目录覆盖默认配置,优化 SQLite 数据库连接字符串处理,确保在不同环境下的兼容性和稳定性。
This commit is contained in:
78
yy-admin-master/installer/YY.Admin.Setup.iss
Normal file
78
yy-admin-master/installer/YY.Admin.Setup.iss
Normal file
@@ -0,0 +1,78 @@
|
||||
; Inno Setup 6 安装脚本 — 用法见同目录 build-installer.ps1
|
||||
; 需先安装: https://jrsoftware.org/isdl.php
|
||||
|
||||
#define MyAppName "智能制造MES工控"
|
||||
#define MyAppExeName "YY.Admin.exe"
|
||||
#define MyAppVersion "1.1.0"
|
||||
#define MyPublisher "星数连科技科技有限公司"
|
||||
; 相对本 .iss 文件位置(installer\ 下的上一级为 yy-admin-master)
|
||||
#define PublishRoot "..\YY.Admin\bin\Release\net8.0-windows10.0.19041\win-x64\publish"
|
||||
|
||||
[Setup]
|
||||
AppId={{B7E8F4A2-9C1D-4E6F-8A3B-2D5E9C1F4A7B}
|
||||
AppName={#MyAppName}
|
||||
AppVersion={#MyAppVersion}
|
||||
AppPublisher={#MyPublisher}
|
||||
AppPublisherURL=https://www.example.com/
|
||||
DefaultDirName={autopf}\{#MyPublisher}\{#MyAppName}
|
||||
DefaultGroupName={#MyAppName}
|
||||
AllowNoIcons=yes
|
||||
OutputDir=..\_installer_output
|
||||
OutputBaseFilename=YY.Admin_Setup_{#MyAppVersion}_win-x64
|
||||
Compression=lzma2/max
|
||||
SolidCompression=yes
|
||||
WizardStyle=modern
|
||||
PrivilegesRequired=admin
|
||||
ArchitecturesAllowed=x64compatible
|
||||
ArchitecturesInstallIn64BitMode=x64compatible
|
||||
MinVersion=10.0.17763
|
||||
DisableProgramGroupPage=no
|
||||
DisableDirPage=no
|
||||
UninstallDisplayIcon={app}\{#MyAppExeName}
|
||||
SetupLogging=yes
|
||||
|
||||
; 向导语言:使用 Inno 自带的 Default.isl(英文)。若本机存在 Languages\ChineseSimplified.isl,
|
||||
; 可改为: Name: "chinesesimp"; MessagesFile: "compiler:Languages\ChineseSimplified.isl"
|
||||
[Languages]
|
||||
Name: "english"; MessagesFile: "compiler:Default.isl"
|
||||
|
||||
[Tasks]
|
||||
Name: "desktopicon"; Description: "在桌面创建快捷方式"; GroupDescription: "附加图标:"; Flags: unchecked
|
||||
Name: "installwebview2"; Description: "安装 Microsoft Edge WebView2 运行时(内嵌网页需要;若已安装会自动跳过)"; GroupDescription: "运行环境:"; Flags: checkedonce
|
||||
|
||||
[Files]
|
||||
; 发布目录完整拷贝(含 Configuration、Updates 等)
|
||||
Source: "{#PublishRoot}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
|
||||
; WebView2 引导安装包(由 build-installer.ps1 下载到 redist;编译时若无文件可加 Flags skipifsourcedoesntexist)
|
||||
Source: "redist\MicrosoftEdgeWebview2Setup.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall skipifsourcedoesntexist
|
||||
|
||||
[Icons]
|
||||
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; WorkingDir: "{app}"
|
||||
Name: "{group}\卸载 {#MyAppName}"; Filename: "{uninstallexe}"
|
||||
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; WorkingDir: "{app}"; Tasks: desktopicon
|
||||
|
||||
[Run]
|
||||
Filename: "{tmp}\MicrosoftEdgeWebview2Setup.exe"; Parameters: "/silent /install"; StatusMsg: "正在安装 WebView2 运行时..."; Flags: waituntilterminated; Tasks: installwebview2; Check: ShouldInstallWebView2()
|
||||
|
||||
Filename: "{app}\{#MyAppExeName}"; Description: "启动 {#MyAppName}"; Flags: nowait postinstall skipifsilent
|
||||
|
||||
[Code]
|
||||
|
||||
// 安装包是否携带了 WebView2 引导程序(已释放到临时目录)
|
||||
function WebView2BootstrapInTmp: Boolean;
|
||||
begin
|
||||
Result := FileExists(ExpandConstant('{tmp}\MicrosoftEdgeWebview2Setup.exe'));
|
||||
end;
|
||||
|
||||
// Evergreen WebView2 是否存在(注册表中存在版本号则认为已装)
|
||||
function WebView2RuntimeInstalled: Boolean;
|
||||
var
|
||||
Ver: String;
|
||||
begin
|
||||
Result := RegQueryStringValue(HKLM, 'SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}', 'pv', Ver) and (Trim(Ver) <> '');
|
||||
end;
|
||||
|
||||
function ShouldInstallWebView2: Boolean;
|
||||
begin
|
||||
Result := WebView2BootstrapInTmp and (not WebView2RuntimeInstalled);
|
||||
end;
|
||||
89
yy-admin-master/installer/build-installer.ps1
Normal file
89
yy-admin-master/installer/build-installer.ps1
Normal file
@@ -0,0 +1,89 @@
|
||||
# Release publish + WebView2 bootstrap download + Inno Setup ISCC
|
||||
# Requires Inno Setup 6 (ISCC.exe)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$Root = Split-Path -Parent $PSScriptRoot
|
||||
$Csproj = Join-Path $Root 'YY.Admin\YY.Admin.csproj'
|
||||
$PublishRel = 'YY.Admin\bin\Release\net8.0-windows10.0.19041\win-x64\publish'
|
||||
$PublishDir = Join-Path $Root $PublishRel
|
||||
$RedistDir = Join-Path $PSScriptRoot 'redist'
|
||||
$WebView2Exe = Join-Path $RedistDir 'MicrosoftEdgeWebview2Setup.exe'
|
||||
$WebView2Url = 'https://go.microsoft.com/fwlink/p/?LinkId=2124703'
|
||||
|
||||
Write-Host '>>> dotnet publish (Release, win-x64)...'
|
||||
dotnet publish $Csproj -c Release `
|
||||
-p:IncludeNativeLibrariesForSelfExtract=true `
|
||||
-p:EnableCompressionInSingleFile=true `
|
||||
--verbosity minimal
|
||||
|
||||
if (-not (Test-Path $PublishDir)) {
|
||||
throw "Publish output not found: $PublishDir"
|
||||
}
|
||||
|
||||
$cfgPublish = Join-Path $PublishDir 'Configuration\appsettings.json'
|
||||
if (-not (Test-Path $cfgPublish)) {
|
||||
throw "Missing Configuration\appsettings.json under publish (ExcludeFromSingleFile required). Path: $cfgPublish"
|
||||
}
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $RedistDir | Out-Null
|
||||
if (-not (Test-Path $WebView2Exe)) {
|
||||
Write-Host '>>> Downloading WebView2 Evergreen bootstrapper...'
|
||||
Invoke-WebRequest -Uri $WebView2Url -OutFile $WebView2Exe -UseBasicParsing
|
||||
}
|
||||
|
||||
function Find-InnoCompiler {
|
||||
if ($env:ISCC -and (Test-Path -LiteralPath $env:ISCC)) {
|
||||
return $env:ISCC
|
||||
}
|
||||
if ($env:INNO_SETUP_DIR) {
|
||||
$p = Join-Path $env:INNO_SETUP_DIR.TrimEnd('\') 'ISCC.exe'
|
||||
if (Test-Path -LiteralPath $p) {
|
||||
return $p
|
||||
}
|
||||
}
|
||||
$cmd = Get-Command 'iscc.exe' -ErrorAction SilentlyContinue
|
||||
if ($cmd -and $cmd.Source -and (Test-Path -LiteralPath $cmd.Source)) {
|
||||
return $cmd.Source
|
||||
}
|
||||
$candidates = @(
|
||||
'D:\Inno Setup 6\ISCC.exe'
|
||||
"${env:ProgramFiles(x86)}\Inno Setup 6\ISCC.exe"
|
||||
"${env:ProgramFiles}\Inno Setup 6\ISCC.exe"
|
||||
"${env:LocalAppData}\Programs\Inno Setup 6\ISCC.exe"
|
||||
)
|
||||
foreach ($c in $candidates) {
|
||||
if ($c -and (Test-Path -LiteralPath $c)) {
|
||||
return $c
|
||||
}
|
||||
}
|
||||
return $null
|
||||
}
|
||||
|
||||
$iscc = Find-InnoCompiler
|
||||
|
||||
if (-not $iscc) {
|
||||
throw @'
|
||||
ISCC.exe not found.
|
||||
|
||||
1) Install Inno Setup 6: https://jrsoftware.org/isdl.php
|
||||
2) Or set env ISCC to full path of ISCC.exe, e.g.:
|
||||
set ISCC=C:\Program Files (x86)\Inno Setup 6\ISCC.exe
|
||||
3) Or set INNO_SETUP_DIR to the Inno Setup 6 folder.
|
||||
|
||||
Then run this script again.
|
||||
'@
|
||||
}
|
||||
|
||||
Write-Host ">>> Using ISCC: $iscc"
|
||||
|
||||
$iss = Join-Path $PSScriptRoot 'YY.Admin.Setup.iss'
|
||||
Write-Host '>>> Compiling installer (working dir: installer)...'
|
||||
Push-Location $PSScriptRoot
|
||||
try {
|
||||
& $iscc "`"$iss`""
|
||||
} finally {
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
$outDir = Join-Path $Root '_installer_output'
|
||||
Write-Host ">>> Done. Output folder: $outDir"
|
||||
2
yy-admin-master/installer/redist/.gitignore
vendored
Normal file
2
yy-admin-master/installer/redist/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
# WebView2 Evergreen 引导程序由 build-installer.ps1 自动下载,不必提交仓库
|
||||
MicrosoftEdgeWebview2Setup.exe
|
||||
Reference in New Issue
Block a user