diff --git a/Software/LogicAnalyzer/Artwork/Ico40.icns b/Software/LogicAnalyzer/Artwork/Ico40.icns new file mode 100644 index 00000000..089b8e1e Binary files /dev/null and b/Software/LogicAnalyzer/Artwork/Ico40.icns differ diff --git a/Software/LogicAnalyzer/publish.ps1 b/Software/LogicAnalyzer/publish.ps1 index 14a09517..826803fc 100644 --- a/Software/LogicAnalyzer/publish.ps1 +++ b/Software/LogicAnalyzer/publish.ps1 @@ -7,8 +7,50 @@ param ( $projectNames = @("LogicAnalyzer", "TerminalCapture") $mergedName = "all-in-one_$packageVersion" +# Empaquetar directorios en ZIP +function Zip-Directory { + param( + [Parameter(Mandatory=$true)] + [string]$sourceDir, + + [Parameter(Mandatory=$true)] + [string]$zipPath, + + [Parameter(Mandatory=$true)] + [string]$architecture, + + [Parameter(Mandatory=$false)] + $executables + ) + + # Eliminar el archivo ZIP si ya existe + if (Test-Path $zipPath) { + Remove-Item -Force $zipPath + } + + # Excluir los paquetes de Windows + if ($architecture -notmatch "win") { + $chmodCmd = if ($executables) { "chmod +x $executables" } else { "true" } + + if ($IsWindows) { + # Convertir las rutas a formato WSL + $wslPath = wsl -e bash -c "wslpath -a '$sourceDir'" + $wslZipPath = wsl -e bash -c "wslpath -a '$zipPath'" + + # Usar WSL para empaquetar y establecer el atributo de ejecutable + wsl -e bash -c "cd $wslPath && $chmodCmd && zip -rq $wslZipPath ." + } else { + # Para Linux y macOS + $zipPathFull = [System.IO.Path]::GetFullPath($zipPath) + bash -c "cd '$sourceDir' && $chmodCmd && zip -rq '$zipPathFull' ." + } + } else { + Compress-Archive -Path "$sourceDir/*" -DestinationPath $zipPath + } +} + # Crear la carpeta de paquetes si no existe -$packagesDir = "..\Packages" +$packagesDir = "../Packages" if (-not (Test-Path $packagesDir)) { New-Item -ItemType Directory -Path $packagesDir } @@ -17,7 +59,7 @@ if (-not (Test-Path $packagesDir)) { Get-ChildItem -Path $packagesDir -Directory | Remove-Item -Recurse -Force # Crea la carpeta de mezcla si no existe -$mergedDir = "..\Merged" +$mergedDir = "../Merged" if (-not (Test-Path $mergedDir)) { New-Item -ItemType Directory -Path $mergedDir } @@ -34,14 +76,14 @@ foreach($projectName in $projectNames) $packageName = $projectName.ToLower() + "_" + $packageVersion # Ruta al archivo .csproj del proyecto que deseas publicar - $projectPath = ".\$projectName\$projectName.csproj" + $projectPath = "./$projectName/$projectName.csproj" # Leer la versión del framework desde el archivo .csproj [xml]$csproj = Get-Content $projectPath $targetFramework = $csproj.Project.PropertyGroup.TargetFramework # Ruta a la carpeta de publicación - $publishDir = ".\$projectName\bin\Release\$targetFramework\publish" + $publishDir = "./$projectName/bin/Release/$targetFramework/publish" # Limpiar la carpeta de publicación if (Test-Path $publishDir) { @@ -52,7 +94,7 @@ foreach($projectName in $projectNames) dotnet build $projectPath -c Release # Obtener todos los perfiles de publicación - $profiles = Get-ChildItem -Path ".\$projectName\" -Recurse -Filter "*.pubxml" | Select-Object -ExpandProperty FullName + $profiles = Get-ChildItem -Path "./$projectName/" -Recurse -Filter "*.pubxml" | Select-Object -ExpandProperty FullName # Publicar usando cada perfil foreach ($profile in $profiles) { @@ -65,31 +107,16 @@ foreach($projectName in $projectNames) $publishSubDirs = Get-ChildItem -Path $publishDir -Directory foreach ($subDir in $publishSubDirs) { $architecture = $subDir.Name - $zipPath = "$packagesDir\$packageName-$architecture.zip" + $zipPath = "$packagesDir/$packageName-$architecture.zip" - Write-Host "Copia de $subDir a $mergedDir\$architecture" + Write-Host "Copia de $subDir a $mergedDir/$architecture" # Copiar los archivos a la carpeta de mezcla Copy-Item -Recurse -Force $subDir.FullName $mergedDir Write-Host "Empaquetando $subDir en $zipPath" - # Eliminar el archivo ZIP si ya existe - if (Test-Path $zipPath) { - Remove-Item -Force $zipPath - } - - # Excluir los paquetes de Windows - if ($architecture -notmatch "win") { - # Convertir las rutas a formato WSL - $wslPath = wsl -e bash -c "wslpath -a '$($subDir.FullName)'" - $wslZipPath = wsl -e bash -c "wslpath -a '$zipPath'" - - # Usar WSL para empaquetar y establecer el atributo de ejecutable - wsl -e bash -c "cd $wslPath && chmod +x $projectName && zip -r $wslZipPath ." - } else { - Compress-Archive -Path "$($subDir.FullName)\*" -DestinationPath $zipPath - } + Zip-Directory -sourceDir $subDir.FullName -zipPath $zipPath -architecture $architecture -executables $projectName } } @@ -98,26 +125,62 @@ foreach($projectName in $projectNames) $mergedSubDirs = Get-ChildItem -Path $mergedDir -Directory foreach ($subDir in $mergedSubDirs) { $architecture = $subDir.Name - $zipPath = "$packagesDir\$mergedName-$architecture.zip" + $zipPath = "$packagesDir/$mergedName-$architecture.zip" - Write-Host "Empaquetando $subDir.FullName en $zipPath" + Write-Host "Empaquetando $subDir en $zipPath" - # Eliminar el archivo ZIP si ya existe - if (Test-Path $zipPath) { - Remove-Item -Force $zipPath - } + Zip-Directory -sourceDir $subDir.FullName -zipPath $zipPath -architecture $architecture -executables $projectNames - # Excluir los paquetes de Windows - if ($architecture -notmatch "win") { - # Convertir las rutas a formato WSL - $wslPath = wsl -e bash -c "wslpath -a '$($subDir.FullName)'" - $wslZipPath = wsl -e bash -c "wslpath -a '$zipPath'" + if ($architecture -like "osx*") { + # Empaquetar app de macOS + $parentDir = Join-Path $mergedDir "LogicAnalyzer-$architecture.app" + $appDir = Join-Path $parentDir "LogicAnalyzer.app" + $contentsDir = Join-Path $appDir "Contents" + $macOSDir = Join-Path $contentsDir "MacOS" + $resourcesDir = Join-Path $contentsDir "Resources" + $zipPath = "$packagesDir/app-LogicAnalyzer_$packageVersion-$architecture.app.zip" - # Usar WSL para empaquetar y establecer el atributo de ejecutable de todos los archivos que coincidan con el nombre del proyecto - wsl -e bash -c "cd $wslPath && chmod +x $projectNames && zip -r $wslZipPath ." - - } else { - Compress-Archive -Path "$($subDir.FullName)\*" -DestinationPath $zipPath + New-Item -ItemType Directory -Force -Path $macOSDir | Out-Null + New-Item -ItemType Directory -Force -Path $resourcesDir | Out-Null + + Get-ChildItem $subDir.FullName | Copy-Item -Recurse -Force -Destination $macOSDir + Copy-Item "Artwork/Ico40.icns" $resourcesDir + + $plistPath = Join-Path $contentsDir "Info.plist" + + $plist = @" + + + + + CFBundleName + LogicAnalyzer + + CFBundleIdentifier + com.gusmanb.LogicAnalyzer + + CFBundleVersion + $packageVersion + + CFBundleShortVersionString + $packageVersion + + CFBundleExecutable + LogicAnalyzer + + LSMinimumSystemVersion + 10.13 + + CFBundlePackageType + APPL + + CFBundleIconFile + Ico40.icns + + +"@ + Set-Content -Path $plistPath -Value $plist -Encoding UTF8 + Zip-Directory -sourceDir $parentDir -zipPath $zipPath -architecture $architecture } }