81 lines
2.8 KiB
PowerShell
81 lines
2.8 KiB
PowerShell
#Requires -Version 5.1
|
|
<#
|
|
.SYNOPSIS
|
|
Genera el instalador (setup) de JNC-NetTools para instalar en el disco.
|
|
.DESCRIPTION
|
|
Asegura que exista el .exe, busca Inno Setup y compila el instalador.
|
|
El setup se genera en dist_installer\JNC-NetTools-Setup-1.0.exe
|
|
.EXAMPLE
|
|
.\Build-Setup.ps1
|
|
#>
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
$ProjectRoot = $PSScriptRoot
|
|
Set-Location $ProjectRoot
|
|
|
|
Write-Host "=== JNC-NetTools - Generar Setup ===" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
# 1. Comprobar que existe el ejecutable
|
|
$exePath = Join-Path $ProjectRoot "dist\JNC-NetTools.exe"
|
|
if (-not (Test-Path $exePath)) {
|
|
Write-Host "No se encontró dist\JNC-NetTools.exe. Ejecutando Build-Windows.ps1..." -ForegroundColor Yellow
|
|
& (Join-Path $ProjectRoot "Build-Windows.ps1")
|
|
if (-not (Test-Path $exePath)) {
|
|
Write-Host "ERROR: No se pudo generar el ejecutable." -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
}
|
|
Write-Host "[1/3] Ejecutable encontrado: dist\JNC-NetTools.exe" -ForegroundColor Green
|
|
|
|
# 2. Buscar Inno Setup (ISCC.exe)
|
|
$iscc = $null
|
|
$paths = @(
|
|
"${env:ProgramFiles(x86)}\Inno Setup 6\ISCC.exe",
|
|
"${env:ProgramFiles}\Inno Setup 6\ISCC.exe",
|
|
"C:\Program Files (x86)\Inno Setup 6\ISCC.exe",
|
|
"C:\Program Files\Inno Setup 6\ISCC.exe"
|
|
)
|
|
foreach ($p in $paths) {
|
|
if ($p -and (Test-Path $p)) {
|
|
$iscc = $p
|
|
break
|
|
}
|
|
}
|
|
if (-not $iscc) {
|
|
$iscc = Get-Command ISCC -ErrorAction SilentlyContinue
|
|
if ($iscc) { $iscc = $iscc.Source }
|
|
}
|
|
if (-not $iscc) {
|
|
Write-Host ""
|
|
Write-Host "ERROR: No se encontró Inno Setup (ISCC.exe)." -ForegroundColor Red
|
|
Write-Host " Instala Inno Setup 6 desde: https://jrsoftware.org/isinfo.php" -ForegroundColor Yellow
|
|
Write-Host " Luego vuelve a ejecutar este script." -ForegroundColor Yellow
|
|
exit 1
|
|
}
|
|
Write-Host "[2/3] Inno Setup: $iscc" -ForegroundColor Green
|
|
|
|
# 3. Compilar el instalador
|
|
$issPath = Join-Path $ProjectRoot "installer\installer.iss"
|
|
if (-not (Test-Path $issPath)) {
|
|
Write-Host "ERROR: No se encontró installer\installer.iss" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
Write-Host "[3/3] Compilando instalador..." -ForegroundColor Yellow
|
|
$outDir = Join-Path $ProjectRoot "dist_installer"
|
|
if (-not (Test-Path $outDir)) { New-Item -ItemType Directory -Path $outDir -Force | Out-Null }
|
|
|
|
& $iscc $issPath
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Host "ERROR: La compilación del instalador falló." -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|
|
$setupExe = Get-ChildItem -Path $outDir -Filter "*.exe" -ErrorAction SilentlyContinue | Select-Object -First 1
|
|
Write-Host ""
|
|
Write-Host "=== Listo ===" -ForegroundColor Cyan
|
|
Write-Host "Instalador: $outDir\$($setupExe.Name)" -ForegroundColor Green
|
|
Write-Host ""
|
|
Write-Host "Ejecuta ese .exe para instalar JNC-NetTools en el disco (por ejemplo en Program Files)." -ForegroundColor Gray
|
|
Write-Host ""
|