param(
|
[string]$Configuration = "Release",
|
[string]$Runtime = "win-x64",
|
[string]$OutputRoot = "artifacts",
|
[switch]$SelfContained
|
)
|
|
$ErrorActionPreference = "Stop"
|
|
$repoRoot = Resolve-Path (Join-Path $PSScriptRoot "..")
|
$projectPath = Join-Path $repoRoot "src\Moli.Desktop\Moli.Desktop.csproj"
|
$outputRootPath = Join-Path $repoRoot $OutputRoot
|
$publishDir = Join-Path $outputRootPath "publish\Moli.Desktop"
|
$zipPath = Join-Path $outputRootPath "Moli.Desktop-$Runtime.zip"
|
$samplesSource = Join-Path $repoRoot "samples\plugins"
|
$samplesTarget = Join-Path $publishDir "samples\plugins"
|
|
New-Item -ItemType Directory -Force -Path $outputRootPath | Out-Null
|
if (Test-Path -LiteralPath $publishDir) {
|
Remove-Item -LiteralPath $publishDir -Recurse -Force
|
}
|
if (Test-Path -LiteralPath $zipPath) {
|
Remove-Item -LiteralPath $zipPath -Force
|
}
|
|
$selfContainedValue = if ($SelfContained) { "true" } else { "false" }
|
dotnet publish $projectPath `
|
--configuration $Configuration `
|
--runtime $Runtime `
|
--self-contained $selfContainedValue `
|
-p:PublishSingleFile=false `
|
--output $publishDir
|
|
if (Test-Path -LiteralPath $samplesSource) {
|
New-Item -ItemType Directory -Force -Path $samplesTarget | Out-Null
|
Copy-Item -Path (Join-Path $samplesSource "*") -Destination $samplesTarget -Recurse -Force
|
}
|
|
Compress-Archive -Path (Join-Path $publishDir "*") -DestinationPath $zipPath -Force
|
|
Write-Host "Portable package created:"
|
Write-Host $zipPath
|