77 lines
2.8 KiB
PowerShell
77 lines
2.8 KiB
PowerShell
[CmdletBinding()]
|
|
param(
|
|
[ValidateSet('WinUI', 'Wpf')]
|
|
[string]$Target = 'WinUI'
|
|
)
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
$projectDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
$ffmpeg = Join-Path $projectDir 'ThirdParty\ffmpeg.exe'
|
|
$ffprobe = Join-Path $projectDir 'ThirdParty\ffprobe.exe'
|
|
|
|
if (-not (Test-Path $ffmpeg) -or -not (Test-Path $ffprobe)) {
|
|
throw 'Add ffmpeg.exe and ffprobe.exe to ThirdParty before publishing.'
|
|
}
|
|
|
|
switch ($Target) {
|
|
'WinUI' {
|
|
$projectPath = Join-Path $projectDir 'AmiReel.WinUI\AmiReel.WinUI.csproj'
|
|
$releaseDir = Join-Path $projectDir 'AmiReel.WinUI\bin\Release\net10.0-windows10.0.26100.0\win-x64'
|
|
$releaseExe = Join-Path $releaseDir 'AmiReel.exe'
|
|
$publishDir = Join-Path $releaseDir 'publish'
|
|
$publishExe = Join-Path $publishDir 'AmiReel.exe'
|
|
$publishArguments = @(
|
|
'publish', $projectPath,
|
|
'-c', 'Release',
|
|
'-r', 'win-x64',
|
|
'--self-contained', 'true',
|
|
'-p:WindowsPackageType=None',
|
|
'-p:PublishSingleFile=true',
|
|
'-p:IncludeNativeLibrariesForSelfExtract=true',
|
|
'-p:EnableCompressionInSingleFile=true'
|
|
)
|
|
}
|
|
'Wpf' {
|
|
$projectPath = Join-Path $projectDir 'AmigaDB.VideoRenderer.csproj'
|
|
$releaseDir = Join-Path $projectDir 'bin\Release\net8.0-windows\win-x64'
|
|
$releaseExe = Join-Path $releaseDir 'AmiReel.exe'
|
|
$publishDir = Join-Path $releaseDir 'publish'
|
|
$publishExe = Join-Path $publishDir 'AmiReel.exe'
|
|
$publishArguments = @(
|
|
'publish', $projectPath,
|
|
'-c', 'Release',
|
|
'-r', 'win-x64',
|
|
'--self-contained', 'true',
|
|
'-p:PublishSingleFile=true',
|
|
'-p:IncludeNativeLibrariesForSelfExtract=true',
|
|
'-p:EnableCompressionInSingleFile=true'
|
|
)
|
|
}
|
|
}
|
|
|
|
if ((Test-Path $releaseExe) -or (Test-Path $publishExe)) {
|
|
$runningReleaseInstances = Get-Process | Where-Object {
|
|
$_.Path -and (
|
|
[string]::Equals($_.Path, $releaseExe, [System.StringComparison]::OrdinalIgnoreCase) -or
|
|
[string]::Equals($_.Path, $publishExe, [System.StringComparison]::OrdinalIgnoreCase)
|
|
)
|
|
}
|
|
|
|
if ($runningReleaseInstances) {
|
|
Write-Host "Stopping running $Target build before publish..." -ForegroundColor Yellow
|
|
$runningReleaseInstances | Stop-Process -Force
|
|
Start-Sleep -Milliseconds 800
|
|
}
|
|
}
|
|
|
|
if (Test-Path $publishDir) {
|
|
Remove-Item -LiteralPath $publishDir -Recurse -Force -ErrorAction SilentlyContinue
|
|
}
|
|
|
|
& dotnet @publishArguments
|
|
|
|
Write-Host "Published $Target to $publishDir" -ForegroundColor Green
|
|
Write-Host "Release folder: $publishDir" -ForegroundColor Cyan
|
|
Write-Host "Executable: $publishExe" -ForegroundColor Cyan
|