Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Software/LogicAnalyzer/Artwork/Ico40.icns
Binary file not shown.
141 changes: 102 additions & 39 deletions Software/LogicAnalyzer/publish.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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
}

}
Expand All @@ -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 = @"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>LogicAnalyzer</string>

<key>CFBundleIdentifier</key>
<string>com.gusmanb.LogicAnalyzer</string>

<key>CFBundleVersion</key>
<string>$packageVersion</string>

<key>CFBundleShortVersionString</key>
<string>$packageVersion</string>

<key>CFBundleExecutable</key>
<string>LogicAnalyzer</string>

<key>LSMinimumSystemVersion</key>
<string>10.13</string>

<key>CFBundlePackageType</key>
<string>APPL</string>

<key>CFBundleIconFile</key>
<string>Ico40.icns</string>
</dict>
</plist>
"@
Set-Content -Path $plistPath -Value $plist -Encoding UTF8
Zip-Directory -sourceDir $parentDir -zipPath $zipPath -architecture $architecture
}
}

Expand Down