Repository navigation
Expand file tree
/
Copy pathbuild.ps1
More file actions
136 lines (109 loc) · 5.16 KB
/
Copy pathbuild.ps1
File metadata and controls
136 lines (109 loc) · 5.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<#
.SYNOPSIS
Compila CustomRes Pro y genera el instalador.
.DESCRIPTION
Ejecuta la cadena completa: compilacion en Release, publicacion
framework-dependent y self-contained, y compilacion del instalador con
Inno Setup si esta disponible.
.PARAMETER SkipInstaller
Omite la generacion del instalador (util si no se tiene Inno Setup).
.EXAMPLE
.\build.ps1
.\build.ps1 -SkipInstaller
#>
[CmdletBinding()]
param(
[switch]$SkipInstaller
)
$ErrorActionPreference = 'Stop'
$root = $PSScriptRoot
$project = Join-Path $root 'src\CustomResPro\CustomResPro.csproj'
function Write-Step([string]$Text) {
Write-Host ''
Write-Host ('=== ' + $Text + ' ===') -ForegroundColor Cyan
}
# ---------------------------------------------------------------------------
Write-Step 'Comprobando el SDK de .NET'
$sdk = & dotnet --version
Write-Host ("SDK de .NET: " + $sdk)
if ([version]($sdk -split '-')[0] -lt [version]'10.0.0') {
throw "Se necesita el SDK de .NET 10.0 o superior. Descarguelo en https://dotnet.microsoft.com/download"
}
# ---------------------------------------------------------------------------
Write-Step 'Limpiando salidas anteriores'
foreach ($dir in @('publish', 'src\CustomResPro\bin', 'src\CustomResPro\obj')) {
$full = Join-Path $root $dir
if (Test-Path $full) {
Remove-Item $full -Recurse -Force
Write-Host ("Eliminado: " + $dir)
}
}
# ---------------------------------------------------------------------------
Write-Step 'Compilando en Release'
& dotnet build $project -c Release -v minimal --nologo
if ($LASTEXITCODE -ne 0) { throw "La compilacion fallo." }
# ---------------------------------------------------------------------------
Write-Step 'Publicando (framework-dependent)'
# Version ligera: requiere el runtime de .NET 10 Desktop instalado.
$fdOut = Join-Path $root 'publish\framework-dependent'
& dotnet publish $project -c Release -r win-x64 --self-contained false -o $fdOut -v minimal --nologo
if ($LASTEXITCODE -ne 0) { throw "La publicacion framework-dependent fallo." }
# ---------------------------------------------------------------------------
Write-Step 'Ejecutando el auto-test'
# Comprueba deteccion de hardware, validacion, persistencia y el ciclo de
# recuperacion completo. No cambia la resolucion en ningun momento.
$testExe = Join-Path $fdOut 'CustomResPro.exe'
$test = Start-Process $testExe -ArgumentList '--selftest' -PassThru -Wait
$reportPath = Join-Path $env:APPDATA 'CustomResPro\selftest-report.txt'
if (Test-Path $reportPath) {
Get-Content $reportPath -Encoding UTF8 | Write-Host
}
if ($test.ExitCode -ne 0) {
throw "El auto-test fallo. Revise $reportPath"
}
Write-Host 'Auto-test superado.' -ForegroundColor Green
# ---------------------------------------------------------------------------
Write-Step 'Publicando (self-contained)'
# Version del instalador: lleva el runtime incluido, no requiere nada previo.
$scOut = Join-Path $root 'publish\self-contained'
& dotnet publish $project -c Release -r win-x64 --self-contained true -o $scOut -v minimal --nologo
if ($LASTEXITCODE -ne 0) { throw "La publicacion self-contained fallo." }
$scSize = (Get-ChildItem $scOut -Recurse -File | Measure-Object -Property Length -Sum).Sum
$fdSize = (Get-ChildItem $fdOut -Recurse -File | Measure-Object -Property Length -Sum).Sum
Write-Host ("framework-dependent: " + [Math]::Round($fdSize / 1MB, 1) + " MB")
Write-Host ("self-contained : " + [Math]::Round($scSize / 1MB, 1) + " MB")
# ---------------------------------------------------------------------------
if ($SkipInstaller) {
Write-Step 'Instalador omitido (-SkipInstaller)'
} else {
Write-Step 'Generando el instalador'
$isccCandidates = @(
(Join-Path $env:LOCALAPPDATA 'Programs\Inno Setup 6\ISCC.exe'),
(Join-Path ${env:ProgramFiles(x86)} 'Inno Setup 6\ISCC.exe'),
(Join-Path $env:ProgramFiles 'Inno Setup 6\ISCC.exe')
)
$iscc = $isccCandidates | Where-Object { Test-Path $_ } | Select-Object -First 1
if (-not $iscc) {
Write-Warning "No se encontro Inno Setup 6. Instalelo con:"
Write-Warning " winget install JRSoftware.InnoSetup"
Write-Warning "y vuelva a ejecutar este script. Las carpetas publish\\ ya estan listas."
} else {
Write-Host ("Usando: " + $iscc)
$iss = Join-Path $root 'installer\CustomResPro.iss'
& $iscc $iss
if ($LASTEXITCODE -ne 0) { throw "La generacion del instalador fallo." }
$setup = Get-ChildItem (Join-Path $root 'publish\installer') -Filter '*.exe' -ErrorAction SilentlyContinue |
Select-Object -First 1
if ($setup) {
Write-Host ("Instalador: " + $setup.FullName + " (" +
[Math]::Round($setup.Length / 1MB, 1) + " MB)") -ForegroundColor Green
}
}
}
# ---------------------------------------------------------------------------
Write-Step 'Terminado'
Write-Host "Ejecutable portable : publish\framework-dependent\CustomResPro.exe" -ForegroundColor Green
Write-Host "Version autonoma : publish\self-contained\CustomResPro.exe" -ForegroundColor Green
if (-not $SkipInstaller) {
Write-Host "Instalador : publish\installer\" -ForegroundColor Green
}