Skip to content

Commit dc875c5

Browse files
author
vp
committed
Enhance task scripts with new publish options and RID selection
1 parent 0eec9b0 commit dc875c5

3 files changed

Lines changed: 79 additions & 16 deletions

File tree

.vscode/tasks-docker.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ switch ($Command.ToLower()) {
178178
Docker-Build -Tag $ImageTag -File $Dockerfile -Context $ProjectDockerContext -NoCache:$NoCache
179179
Docker-Run -Tag $ImageTag -Name $ContainerName -Network $Network -HostPort $HostPort -ContainerPort $ContainerPort
180180
}
181-
'docker-build' {
182-
Docker-Build -Tag $ImageTag -File $Dockerfile -Context $ProjectDockerContext -NoCache:$NoCache
183-
}
181+
# 'docker-build' {
182+
# Docker-Build -Tag $ImageTag -File $Dockerfile -Context $ProjectDockerContext -NoCache:$NoCache
183+
# }
184184
'docker-build-debug' {
185185
$tag = "$ImageTag-debug"
186186
Write-Step "Using debug tag: $tag"

.vscode/tasks-dotnet.ps1

Lines changed: 69 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,50 @@ function Invoke-Dotnet([string[]]$Arguments){
1212
if ($LASTEXITCODE -ne 0){ throw "dotnet command failed ($LASTEXITCODE)" }
1313
}
1414

15+
function Select-Rid {
16+
param([string[]]$Rids)
17+
if(-not $Rids){ return $null }
18+
try {
19+
Import-Module PwshSpectreConsole -ErrorAction Stop
20+
$selection = Read-SpectreSelection -Title 'Select RID (blank for framework-dependent)' -Choices ($Rids + 'Framework-Dependent' + 'Cancel') -EnableSearch -PageSize 15
21+
if(-not $selection -or $selection -eq 'Cancel'){ return $null }
22+
if($selection -eq 'Framework-Dependent'){ return $null }
23+
return $selection
24+
} catch {
25+
Write-Host 'Spectre selection unavailable; proceeding framework-dependent.' -ForegroundColor Yellow
26+
return $null
27+
}
28+
}
29+
30+
function Copy-PublishOutput {
31+
param(
32+
[string]$ProjectPath,
33+
[string]$Rid # optional for RID-specific publish
34+
)
35+
try {
36+
if(-not $ProjectPath){ return }
37+
$projDir = Split-Path $ProjectPath -Parent
38+
# Determine publish folder (RID-specific or generic)
39+
$publishDir = if($Rid){ Join-Path $projDir "bin/Release/net9.0/$Rid/publish" } else { Join-Path $projDir "bin/Release/net9.0/publish" }
40+
if(-not (Test-Path $publishDir)){ Write-Host "Publish output not found: $publishDir" -ForegroundColor Yellow; return }
41+
$root = Split-Path $PSScriptRoot -Parent
42+
$destRoot = Join-Path $root '.tmp/publish'
43+
New-Item -ItemType Directory -Force -Path $destRoot | Out-Null
44+
$stamp = Get-Date -Format 'yyyyMMdd_HHmmss'
45+
$dest = Join-Path $destRoot $stamp
46+
New-Item -ItemType Directory -Force -Path $dest | Out-Null
47+
Write-Host "Copying publish output -> $dest" -ForegroundColor Cyan
48+
Copy-Item (Join-Path $publishDir '*') -Destination $dest -Recurse -Force
49+
# Write summary JSON
50+
$files = Get-ChildItem -Path $dest -Recurse -File | Select-Object -ExpandProperty FullName
51+
$summary = [ordered]@{ project=$ProjectPath; rid=$Rid; source=$publishDir; destination=$dest; fileCount=$files.Count; timestamp=$stamp }
52+
$summary | ConvertTo-Json -Depth 5 | Out-File (Join-Path $dest 'publish_summary.json') -Encoding UTF8
53+
Write-Host "Publish output copied ($($files.Count) files)." -ForegroundColor Green
54+
} catch {
55+
Write-Host "Failed to copy publish output: $($_.Exception.Message)" -ForegroundColor Yellow
56+
}
57+
}
58+
1559
# Common logger args as array
1660
$logArgs = @('--nologo','/property:GenerateFullPaths=true','/consoleloggerparameters:NoSummary')
1761

@@ -46,14 +90,35 @@ switch ($Command.ToLowerInvariant()) {
4690
}
4791
'analyzers' { Invoke-Dotnet @('build',$SolutionPath,'-warnaserror','/p:RunAnalyzers=true','/p:EnableNETAnalyzers=true','/p:AnalysisLevel=latest') }
4892
'project-build' { if (-not $ProjectPath) { throw 'ProjectPath required for project-build' }; Invoke-Dotnet (@('build',$ProjectPath) + $logArgs) }
49-
'project-publish' { if (-not $ProjectPath) { throw 'ProjectPath required for project-publish' }; Invoke-Dotnet (@('publish',$ProjectPath) + $logArgs) }
50-
'project-publish-release' { if (-not $ProjectPath) { throw 'ProjectPath required for project-publish-release' }; Invoke-Dotnet (@('publish',$ProjectPath,'-c','Release') + $logArgs) }
93+
'project-publish' {
94+
if (-not $ProjectPath) { throw 'ProjectPath required for project-publish' }
95+
$rids = @('win-x64','win-x86','win-arm64','linux-x64','linux-musl-x64','linux-musl-arm64','linux-arm','linux-arm64')
96+
$rid = Select-Rid -Rids $rids
97+
$args = @('publish',$ProjectPath) + $logArgs
98+
if($rid){ $args += @('-r',$rid,'--self-contained','true') }
99+
Invoke-Dotnet $args
100+
Copy-PublishOutput -ProjectPath $ProjectPath -Rid $rid
101+
}
102+
'project-publish-release' {
103+
if (-not $ProjectPath) { throw 'ProjectPath required for project-publish-release' }
104+
$rids = @('win-x64','win-x86','win-arm64','linux-x64','linux-musl-x64','linux-musl-arm64','linux-arm','linux-arm64')
105+
$rid = Select-Rid -Rids $rids
106+
$args = @('publish',$ProjectPath,'-c','Release') + $logArgs
107+
if($rid){ $args += @('-r',$rid,'--self-contained','true') }
108+
Invoke-Dotnet $args
109+
Copy-PublishOutput -ProjectPath $ProjectPath -Rid $rid
110+
}
51111
'project-publish-sc' {
52112
if (-not $ProjectPath) { throw 'ProjectPath required for project-publish-sc' }
53-
# Self-contained single-file trimmed publish (win-x64 default runtime identifier)
54-
$rid = 'win-x64'
113+
# Self-contained single-file publish reusing Select-Rid helper
114+
$rids = @('win-x64','win-x86','win-arm64','linux-x64','linux-musl-x64','linux-musl-arm64','linux-arm','linux-arm64')
115+
$rid = Select-Rid -Rids $rids
116+
if(-not $rid){ Write-Host 'Self-contained publish requires a RID; cancelled.' -ForegroundColor Yellow; break }
117+
Write-Host "Publishing self-contained single-file for RID: $rid" -ForegroundColor Cyan
55118
$publishArgs = @('publish',$ProjectPath,'-c','Release','-r',$rid,'--self-contained','true','/p:PublishSingleFile=true','/p:PublishTrimmed=false') + $logArgs
56119
Invoke-Dotnet $publishArgs
120+
Write-Host "Self-contained publish complete for RID $rid" -ForegroundColor Green
121+
Copy-PublishOutput -ProjectPath $ProjectPath -Rid $rid
57122
}
58123
'pack-modules' {
59124
# Packs each module project (Domain/Application/Infrastructure/Presentation) into .tmp/packages

tasks.ps1

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ function Invoke-Coverage { & pwsh -NoProfile -File (Join-Path $PSScriptRoot '.vs
5757
function Invoke-CoverageHtml { & pwsh -NoProfile -File (Join-Path $PSScriptRoot '.vscode/tasks-coverage.ps1') -Html }
5858
function Invoke-OpenApiLint { & pwsh -NoProfile -File (Join-Path $PSScriptRoot '.vscode/tasks-openapi.ps1') lint }
5959
function Invoke-Misc([string]$cmd){ & pwsh -NoProfile -File (Join-Path $PSScriptRoot '.vscode/tasks-misc.ps1') $cmd }
60-
6160
function Invoke-Docker([string]$mode){ & pwsh -NoProfile -File (Join-Path $PSScriptRoot '.vscode/tasks-docker.ps1') $mode }
62-
6361
function Invoke-Ef([string]$efCmd){ & pwsh -NoProfile -File (Join-Path $PSScriptRoot '.vscode/tasks-ef.ps1') $efCmd }
6462
function Invoke-Diagnostics([string]$diagCmd){ & pwsh -NoProfile -File (Join-Path $PSScriptRoot '.vscode/tasks-diagnostics.ps1') -Command $diagCmd }
6563
function Invoke-Compliance([string]$compCmd){ & pwsh -NoProfile -File (Join-Path $PSScriptRoot '.vscode/tasks-compliance.ps1') -Command $compCmd }
@@ -98,7 +96,9 @@ $tasks = [ordered]@{
9896
'ef-reset' = @{ Label='EF Reset (Squash)'; Script={ Invoke-Ef 'reset' } }
9997
'ef-script' = @{ Label='EF Export SQL Script'; Script={ Invoke-Ef 'script' } }
10098
'docker-build-run' = @{ Label='Docker Build & Run'; Script={ Invoke-Docker 'docker-build-run' } }
101-
'docker-build' = @{ Label='Docker Build'; Script={ Invoke-Docker 'docker-build' } }
99+
# 'docker-build' = @{ Label='Docker Build'; Script={ Invoke-Docker 'docker-build' } }
100+
'docker-build-debug' = @{ Label='Docker Build'; Script={ Invoke-Docker 'docker-build-debug' } }
101+
'docker-build-release' = @{ Label='Docker Build (Release)'; Script={ Invoke-Docker 'docker-build-release' } }
102102
'docker-run' = @{ Label='Docker Run'; Script={ Invoke-Docker 'docker-run' } }
103103
'docker-stop' = @{ Label='Docker Stop'; Script={ Invoke-Docker 'docker-stop' } }
104104
'docker-remove' = @{ Label='Docker Remove'; Script={ Invoke-Docker 'docker-remove' } }
@@ -117,7 +117,7 @@ $tasks = [ordered]@{
117117
'server-build' = @{ Label='Server Project Build'; Script={ Invoke-DotnetScript 'project-build' (Join-Path $PSScriptRoot 'src/Presentation.Web.Server/Presentation.Web.Server.csproj') } }
118118
'server-publish' = @{ Label='Server Project Publish'; Script={ Invoke-DotnetScript 'project-publish' (Join-Path $PSScriptRoot 'src/Presentation.Web.Server/Presentation.Web.Server.csproj') } }
119119
'server-publish-release' = @{ Label='Server Project Publish (Release)'; Script={ Invoke-DotnetScript 'project-publish-release' (Join-Path $PSScriptRoot 'src/Presentation.Web.Server/Presentation.Web.Server.csproj') } }
120-
'server-publish-sc' = @{ Label='Server Project Publish (Self-Contained Single-File)'; Script={ Invoke-DotnetScript 'project-publish-sc' (Join-Path $PSScriptRoot 'src/Presentation.Web.Server/Presentation.Web.Server.csproj') } }
120+
'server-publish-sc' = @{ Label='Server Project Publish (Release, Single-File)'; Script={ Invoke-DotnetScript 'project-publish-sc' (Join-Path $PSScriptRoot 'src/Presentation.Web.Server/Presentation.Web.Server.csproj') } }
121121
'server-watch' = @{ Label='Server Project Watch Run'; Script={ Invoke-DotnetScript 'project-watch' (Join-Path $PSScriptRoot 'src/Presentation.Web.Server/Presentation.Web.Server.csproj') } }
122122
'server-run-dev' = @{ Label='Server Project Run Dev'; Script={ Invoke-DotnetScript 'project-run' (Join-Path $PSScriptRoot 'src/Presentation.Web.Server/Presentation.Web.Server.csproj') } }
123123
'server-watch-fast' = @{ Label='Server Project Watch Fast'; Script={ Invoke-DotnetScript 'project-watch-fast' (Join-Path $PSScriptRoot 'src/Presentation.Web.Server/Presentation.Web.Server.csproj') } }
@@ -127,17 +127,15 @@ $tasks = [ordered]@{
127127
'misc-digest' = @{ Label='Misc Digest Sources'; Script={ Invoke-Misc 'digest' } }
128128
'misc-repl' = @{ Label='Misc C# REPL'; Script={ Invoke-Misc 'repl' } }
129129
'bench' = @{ Label='Diagnostics Benchmarks'; Script={ Invoke-Diagnostics 'bench' } }
130-
'bench-select' = @{ Label='Diagnostics Benchmarks (Select Project)'; Script={ Invoke-Diagnostics 'bench-select' } }
130+
'bench-select' = @{ Label='Diagnostics Benchmarks (Project)'; Script={ Invoke-Diagnostics 'bench-select' } }
131131
'trace-flame' = @{ Label='Diagnostics Trace (Flame)'; Script={ Invoke-Diagnostics 'trace-flame' } }
132132
'trace-cpu' = @{ Label='Diagnostics Trace (CPU SampleProfiler)'; Script={ Invoke-Diagnostics 'trace-cpu' } }
133133
'trace-gc' = @{ Label='Diagnostics Trace (GC Focus)'; Script={ Invoke-Diagnostics 'trace-gc' } }
134134
'dump-heap' = @{ Label='Diagnostics Heap Dump'; Script={ Invoke-Diagnostics 'dump-heap' } }
135135
'gc-stats' = @{ Label='Diagnostics GC Stats'; Script={ Invoke-Diagnostics 'gc-stats' } }
136136
'aspnet-metrics' = @{ Label='Diagnostics ASP.NET Core Metrics'; Script={ Invoke-Diagnostics 'aspnet-metrics' } }
137137
'diag-quick' = @{ Label='Diagnostics Quick Set (CPU + GC + ASP.NET)'; Script={ Invoke-Diagnostics 'quick' } }
138-
'coverage-open' = @{ Label='Coverage Report (HTML + Open)'; Script={ & pwsh -NoProfile -File (Join-Path $PSScriptRoot '.vscode/tasks-coverage.ps1') -Html -Open } }
139-
'docker-build-debug' = @{ Label='Docker Build (Debug)'; Script={ Invoke-Docker 'docker-build-debug' } }
140-
'docker-build-release' = @{ Label='Docker Build (Release)'; Script={ Invoke-Docker 'docker-build-release' } }
138+
'coverage-open' = @{ Label='Coverage Report (HTML)'; Script={ & pwsh -NoProfile -File (Join-Path $PSScriptRoot '.vscode/tasks-coverage.ps1') -Html -Open } }
141139
'licenses' = @{ Label='Generate License Reports'; Script={ Invoke-Compliance 'licenses' } }
142140
}
143141

@@ -146,7 +144,7 @@ $categories = [ordered]@{
146144
'Testing & Quality' = @('test-unit','test-int','test-unit-all','test-int-all','coverage','coverage-html','coverage-open','coverage-all-html')
147145
'EF & Persistence' = @('ef-info','ef-list','ef-add','ef-remove','ef-removeall','ef-apply','ef-update','ef-recreate','ef-undo','ef-status','ef-reset','ef-script')
148146
'Publishing & Packaging' = @('server-publish','server-publish-release','server-publish-sc','pack','pack-modules')
149-
'Docker & Containers' = @('docker-build-run','docker-build','docker-build-debug','docker-build-release','docker-run','docker-stop','docker-remove','compose-up','compose-up-pull','compose-down','compose-down-clean')
147+
'Docker & Containers' = @('docker-build-run','docker-build-debug','docker-build-release','docker-run','docker-stop','docker-remove','compose-up','compose-up-pull','compose-down','compose-down-clean')
150148
'Security & Compliance' = @('vulnerabilities','vulnerabilities-deep','outdated','outdated-json','licenses')
151149
'API & Spec' = @('openapi-lint')
152150
'Utilities' = @('misc-clean','misc-digest','misc-repl')

0 commit comments

Comments
 (0)