Skip to content

Commit 071bbf9

Browse files
updates
1 parent 9897621 commit 071bbf9

23 files changed

Lines changed: 80 additions & 157 deletions

scripts/migrate-prompt.md

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,13 @@ If Pester integration tests exist for this command, establish a baseline BEFORE
3434

3535
```bash
3636
pwsh -NoProfile -Command '
37-
Import-Module c:\github\dbatools.library\dbatools.library.psd1 -Force
3837
Import-Module c:\github\dbatools-ralph\dbatools.psm1 -Force
3938
. c:\github\dbatools-ralph\private\testing\Invoke-ManualPester.ps1
4039
Invoke-ManualPester -Path c:\github\dbatools-ralph\tests\{CommandName}.Tests.ps1 -TestIntegration
4140
'
4241
```
4342

44-
**Always use `pwsh -NoProfile`** to spawn a fresh process. This avoids DLL locking from your current session and ensures a clean module load. Import `dbatools.library` from the local repo FIRST so it satisfies the `RequiredModules` dependency before dbatools loads.
43+
**Always use `pwsh -NoProfile`** to spawn a fresh process. For the baseline, the installed `dbatools.library` module is fine — a fresh process won't have the DLL locked even if another session does.
4544

4645
Record the pass/fail/skip counts. If no test file exists at `c:\github\dbatools-ralph\tests\{CommandName}.Tests.ps1`, note "No Pester tests" and continue — Pester testing steps later will be skipped.
4746

@@ -141,40 +140,36 @@ if (ShouldProcess(target, String.Format("Removing {0}", name)))
141140

142141
### 5. Build and Deploy
143142

143+
#### Compile
144+
144145
```bash
145146
dotnet build project/dbatools/dbatools.csproj
146147
```
147148

148149
If it fails, fix errors and rebuild. Do not proceed until the build succeeds.
149150

150-
#### Deploy the built DLL for testing
151+
#### Dev-build a loadable module
151152

152-
After a successful build, copy the compiled DLL to the local module staging directory so that Pester tests can load it. The installed module at `C:\Program Files\PowerShell\Modules\dbatools.library\` may be locked by another PowerShell session**never fight the lock**. Always deploy to the local repo path instead.
153+
The installed `dbatools.library` at `C:\Program Files\PowerShell\Modules\` may be locked by another session. **Never fight the lock.** Instead, build a complete loadable module into `artifacts/dbatools.library/` using the dev-build script:
153154

154155
```bash
155-
# Create staging dirs if they don't exist
156-
mkdir -p c:/github/dbatools.library/core/lib
157-
mkdir -p c:/github/dbatools.library/desktop/lib
158-
159-
# Copy net8.0 build output to local staging (for PS Core / PS 7+)
160-
cp project/dbatools/bin/Debug/net8.0/dbatools.dll c:/github/dbatools.library/core/lib/dbatools.dll
161-
162-
# Copy net472 build output to local staging (for Windows PowerShell 5.1)
163-
cp project/dbatools/bin/Debug/net472/dbatools.dll c:/github/dbatools.library/desktop/lib/dbatools.dll
156+
pwsh -NoProfile -File build/build-dev.ps1
164157
```
165158

166-
These paths are gitignored (`lib/` is in `.gitignore`). The `dbatools.library.psm1` loads from `$PSScriptRoot/core/lib/` or `$PSScriptRoot/desktop/lib/`, so when importing from the local repo path, it will find the freshly built DLL.
159+
This runs `dotnet publish` (which includes all ~142 dependency DLLs — SMO, SqlClient, etc.), copies them alongside the freshly built `dbatools.dll`, and adds the module manifest/loader. The output at `artifacts/dbatools.library/` is a fully self-contained, loadable module.
160+
161+
The `artifacts/` directory is gitignored.
167162

168-
#### Load the local module for Pester testing
163+
#### Load the dev-built module for Pester testing
169164

170-
When running Pester tests, import `dbatools.library` from the local repo FIRST so it takes precedence over the installed version:
165+
When running Pester tests, **always spawn a fresh `pwsh -NoProfile` process** and import the dev-built library FIRST:
171166

172167
```powershell
173-
Import-Module c:\github\dbatools.library\dbatools.library.psd1 -Force
168+
Import-Module c:\github\dbatools.library\artifacts\dbatools.library\dbatools.library.psd1 -Force
174169
Import-Module c:\github\dbatools-ralph\dbatools.psm1 -Force
175170
```
176171

177-
The `-Force` on the library import ensures it replaces any previously loaded version. Doing this BEFORE importing dbatools-ralph satisfies the `RequiredModules` dependency with the local build.
172+
Loading the dev-built library first satisfies dbatools-ralph's `RequiredModules = 'dbatools.library'` dependency with the freshly built version, so it won't try to load the installed (potentially locked) copy.
178173

179174
### 5b. Run Tests
180175

@@ -373,18 +368,18 @@ Edit `c:\github\dbatools.library\dbatools.library.psd1` — add `'{CommandName}'
373368

374369
**This step is MANDATORY if a Pester test file exists.** Skip only if Step 0 noted "No Pester tests."
375370

376-
Spawn a fresh PowerShell process to pick up the C# cmdlet (the PS1 is now archived). Import the local `dbatools.library` first so the freshly built DLL is loaded:
371+
Spawn a fresh PowerShell process to pick up the C# cmdlet (the PS1 is now archived). Import the **dev-built** `dbatools.library` (from Step 5) first so the freshly built DLL with your new cmdlet is loaded:
377372

378373
```bash
379374
pwsh -NoProfile -Command '
380-
Import-Module c:\github\dbatools.library\dbatools.library.psd1 -Force
375+
Import-Module c:\github\dbatools.library\artifacts\dbatools.library\dbatools.library.psd1 -Force
381376
Import-Module c:\github\dbatools-ralph\dbatools.psm1 -Force
382377
. c:\github\dbatools-ralph\private\testing\Invoke-ManualPester.ps1
383378
Invoke-ManualPester -Path c:\github\dbatools-ralph\tests\{CommandName}.Tests.ps1 -TestIntegration
384379
'
385380
```
386381

387-
**Always use `pwsh -NoProfile`** — never test in the current session where the installed DLL may be locked or a stale module is loaded.
382+
**Always use `pwsh -NoProfile`** — never test in the current session where the installed DLL may be locked or a stale module is loaded. The dev-built module at `artifacts/dbatools.library/` contains your freshly compiled `dbatools.dll` plus all dependency DLLs.
388383

389384
Compare results against the Pester baseline from Step 0:
390385
- **All tests that passed in the baseline MUST still pass.** A previously-passing test that now fails is a regression in your C# implementation.

scripts/ralph-migrate-ag.ps1

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ if (Test-Path $SignalFile) {
4646
exit 0
4747
}
4848

49-
# Load agent definitions for --agents flag
50-
. "$PSScriptRoot\ralph-agents.ps1"
51-
$agentsJson = Get-RalphAgentsJson -RepoRoot $RepoRoot
5249

5350
for ($i = 1; $i -le $MaxIterations; $i++) {
5451
$status = Get-TrackerStatus
@@ -76,11 +73,10 @@ for ($i = 1; $i -le $MaxIterations; $i++) {
7673
'--no-session-persistence'
7774
'--verbose'
7875
'--output-format', 'stream-json'
79-
'--agents', $agentsJson
80-
'-p', $promptContent
76+
'-p', '-'
8177
)
8278

83-
& claude @claudeArgs 2>&1 | ForEach-Object {
79+
$promptContent | & claude @claudeArgs 2>&1 | ForEach-Object {
8480
$line = $PSItem
8581
try {
8682
$obj = $line | ConvertFrom-Json -ErrorAction Stop
@@ -140,4 +136,4 @@ $final = Get-TrackerStatus
140136
Write-Host ("`n=== $DomainUpper Final: {0}/{1} done ===" -f $final.Done, $final.Total) -ForegroundColor Cyan
141137
if ($final.Pending -gt 0) {
142138
Write-Host "[WARN] $($final.Pending) commands still pending" -ForegroundColor Yellow
143-
}
139+
}

scripts/ralph-migrate-agent.ps1

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ if (Test-Path $SignalFile) {
4646
exit 0
4747
}
4848

49-
# Load agent definitions for --agents flag
50-
. "$PSScriptRootalph-agents.ps1"
5149
$agentsJson = Get-RalphAgentsJson -RepoRoot $RepoRoot
5250

5351
for ($i = 1; $i -le $MaxIterations; $i++) {
@@ -76,11 +74,10 @@ for ($i = 1; $i -le $MaxIterations; $i++) {
7674
'--no-session-persistence'
7775
'--verbose'
7876
'--output-format', 'stream-json'
79-
'--agents', $agentsJson
80-
'-p', $promptContent
77+
'-p', '-'
8178
)
8279

83-
& claude @claudeArgs 2>&1 | ForEach-Object {
80+
$promptContent | & claude @claudeArgs 2>&1 | ForEach-Object {
8481
$line = $PSItem
8582
try {
8683
$obj = $line | ConvertFrom-Json -ErrorAction Stop
@@ -140,4 +137,4 @@ $final = Get-TrackerStatus
140137
Write-Host ("`n=== $DomainUpper Final: {0}/{1} done ===" -f $final.Done, $final.Total) -ForegroundColor Cyan
141138
if ($final.Pending -gt 0) {
142139
Write-Host "[WARN] $($final.Pending) commands still pending" -ForegroundColor Yellow
143-
}
140+
}

scripts/ralph-migrate-backup.ps1

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ if (Test-Path $SignalFile) {
4646
exit 0
4747
}
4848

49-
# Load agent definitions for --agents flag
50-
. "$PSScriptRootalph-agents.ps1"
5149
$agentsJson = Get-RalphAgentsJson -RepoRoot $RepoRoot
5250

5351
for ($i = 1; $i -le $MaxIterations; $i++) {
@@ -76,11 +74,10 @@ for ($i = 1; $i -le $MaxIterations; $i++) {
7674
'--no-session-persistence'
7775
'--verbose'
7876
'--output-format', 'stream-json'
79-
'--agents', $agentsJson
80-
'-p', $promptContent
77+
'-p', '-'
8178
)
8279

83-
& claude @claudeArgs 2>&1 | ForEach-Object {
80+
$promptContent | & claude @claudeArgs 2>&1 | ForEach-Object {
8481
$line = $PSItem
8582
try {
8683
$obj = $line | ConvertFrom-Json -ErrorAction Stop
@@ -140,4 +137,4 @@ $final = Get-TrackerStatus
140137
Write-Host ("`n=== $DomainUpper Final: {0}/{1} done ===" -f $final.Done, $final.Total) -ForegroundColor Cyan
141138
if ($final.Pending -gt 0) {
142139
Write-Host "[WARN] $($final.Pending) commands still pending" -ForegroundColor Yellow
143-
}
140+
}

scripts/ralph-migrate-computer.ps1

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ if (Test-Path $SignalFile) {
4646
exit 0
4747
}
4848

49-
# Load agent definitions for --agents flag
50-
. "$PSScriptRootalph-agents.ps1"
5149
$agentsJson = Get-RalphAgentsJson -RepoRoot $RepoRoot
5250

5351
for ($i = 1; $i -le $MaxIterations; $i++) {
@@ -76,11 +74,10 @@ for ($i = 1; $i -le $MaxIterations; $i++) {
7674
'--no-session-persistence'
7775
'--verbose'
7876
'--output-format', 'stream-json'
79-
'--agents', $agentsJson
80-
'-p', $promptContent
77+
'-p', '-'
8178
)
8279

83-
& claude @claudeArgs 2>&1 | ForEach-Object {
80+
$promptContent | & claude @claudeArgs 2>&1 | ForEach-Object {
8481
$line = $PSItem
8582
try {
8683
$obj = $line | ConvertFrom-Json -ErrorAction Stop
@@ -140,4 +137,4 @@ $final = Get-TrackerStatus
140137
Write-Host ("`n=== $DomainUpper Final: {0}/{1} done ===" -f $final.Done, $final.Total) -ForegroundColor Cyan
141138
if ($final.Pending -gt 0) {
142139
Write-Host "[WARN] $($final.Pending) commands still pending" -ForegroundColor Yellow
143-
}
140+
}

scripts/ralph-migrate-config.ps1

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ if (Test-Path $SignalFile) {
4646
exit 0
4747
}
4848

49-
# Load agent definitions for --agents flag
50-
. "$PSScriptRootalph-agents.ps1"
5149
$agentsJson = Get-RalphAgentsJson -RepoRoot $RepoRoot
5250

5351
for ($i = 1; $i -le $MaxIterations; $i++) {
@@ -76,11 +74,10 @@ for ($i = 1; $i -le $MaxIterations; $i++) {
7674
'--no-session-persistence'
7775
'--verbose'
7876
'--output-format', 'stream-json'
79-
'--agents', $agentsJson
80-
'-p', $promptContent
77+
'-p', '-'
8178
)
8279

83-
& claude @claudeArgs 2>&1 | ForEach-Object {
80+
$promptContent | & claude @claudeArgs 2>&1 | ForEach-Object {
8481
$line = $PSItem
8582
try {
8683
$obj = $line | ConvertFrom-Json -ErrorAction Stop
@@ -140,4 +137,4 @@ $final = Get-TrackerStatus
140137
Write-Host ("`n=== $DomainUpper Final: {0}/{1} done ===" -f $final.Done, $final.Total) -ForegroundColor Cyan
141138
if ($final.Pending -gt 0) {
142139
Write-Host "[WARN] $($final.Pending) commands still pending" -ForegroundColor Yellow
143-
}
140+
}

scripts/ralph-migrate-database.ps1

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ if (Test-Path $SignalFile) {
4646
exit 0
4747
}
4848

49-
# Load agent definitions for --agents flag
50-
. "$PSScriptRootalph-agents.ps1"
5149
$agentsJson = Get-RalphAgentsJson -RepoRoot $RepoRoot
5250

5351
for ($i = 1; $i -le $MaxIterations; $i++) {
@@ -76,11 +74,10 @@ for ($i = 1; $i -le $MaxIterations; $i++) {
7674
'--no-session-persistence'
7775
'--verbose'
7876
'--output-format', 'stream-json'
79-
'--agents', $agentsJson
80-
'-p', $promptContent
77+
'-p', '-'
8178
)
8279

83-
& claude @claudeArgs 2>&1 | ForEach-Object {
80+
$promptContent | & claude @claudeArgs 2>&1 | ForEach-Object {
8481
$line = $PSItem
8582
try {
8683
$obj = $line | ConvertFrom-Json -ErrorAction Stop
@@ -140,4 +137,4 @@ $final = Get-TrackerStatus
140137
Write-Host ("`n=== $DomainUpper Final: {0}/{1} done ===" -f $final.Done, $final.Total) -ForegroundColor Cyan
141138
if ($final.Pending -gt 0) {
142139
Write-Host "[WARN] $($final.Pending) commands still pending" -ForegroundColor Yellow
143-
}
140+
}

scripts/ralph-migrate-dbmail.ps1

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ if (Test-Path $SignalFile) {
4646
exit 0
4747
}
4848

49-
# Load agent definitions for --agents flag
50-
. "$PSScriptRootalph-agents.ps1"
5149
$agentsJson = Get-RalphAgentsJson -RepoRoot $RepoRoot
5250

5351
for ($i = 1; $i -le $MaxIterations; $i++) {
@@ -76,11 +74,10 @@ for ($i = 1; $i -le $MaxIterations; $i++) {
7674
'--no-session-persistence'
7775
'--verbose'
7876
'--output-format', 'stream-json'
79-
'--agents', $agentsJson
80-
'-p', $promptContent
77+
'-p', '-'
8178
)
8279

83-
& claude @claudeArgs 2>&1 | ForEach-Object {
80+
$promptContent | & claude @claudeArgs 2>&1 | ForEach-Object {
8481
$line = $PSItem
8582
try {
8683
$obj = $line | ConvertFrom-Json -ErrorAction Stop
@@ -140,4 +137,4 @@ $final = Get-TrackerStatus
140137
Write-Host ("`n=== $DomainUpper Final: {0}/{1} done ===" -f $final.Done, $final.Total) -ForegroundColor Cyan
141138
if ($final.Pending -gt 0) {
142139
Write-Host "[WARN] $($final.Pending) commands still pending" -ForegroundColor Yellow
143-
}
140+
}

scripts/ralph-migrate-dbobject.ps1

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ if (Test-Path $SignalFile) {
4646
exit 0
4747
}
4848

49-
# Load agent definitions for --agents flag
50-
. "$PSScriptRootalph-agents.ps1"
5149
$agentsJson = Get-RalphAgentsJson -RepoRoot $RepoRoot
5250

5351
for ($i = 1; $i -le $MaxIterations; $i++) {
@@ -76,11 +74,10 @@ for ($i = 1; $i -le $MaxIterations; $i++) {
7674
'--no-session-persistence'
7775
'--verbose'
7876
'--output-format', 'stream-json'
79-
'--agents', $agentsJson
80-
'-p', $promptContent
77+
'-p', '-'
8178
)
8279

83-
& claude @claudeArgs 2>&1 | ForEach-Object {
80+
$promptContent | & claude @claudeArgs 2>&1 | ForEach-Object {
8481
$line = $PSItem
8582
try {
8683
$obj = $line | ConvertFrom-Json -ErrorAction Stop
@@ -140,4 +137,4 @@ $final = Get-TrackerStatus
140137
Write-Host ("`n=== $DomainUpper Final: {0}/{1} done ===" -f $final.Done, $final.Total) -ForegroundColor Cyan
141138
if ($final.Pending -gt 0) {
142139
Write-Host "[WARN] $($final.Pending) commands still pending" -ForegroundColor Yellow
143-
}
140+
}

scripts/ralph-migrate-domain-template.ps1

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ if (Test-Path $SignalFile) {
4646
exit 0
4747
}
4848

49-
# Load agent definitions for --agents flag
50-
. "$PSScriptRoot\ralph-agents.ps1"
51-
$agentsJson = Get-RalphAgentsJson -RepoRoot $RepoRoot
5249

5350
for ($i = 1; $i -le $MaxIterations; $i++) {
5451
$status = Get-TrackerStatus
@@ -76,11 +73,10 @@ for ($i = 1; $i -le $MaxIterations; $i++) {
7673
'--no-session-persistence'
7774
'--verbose'
7875
'--output-format', 'stream-json'
79-
'--agents', $agentsJson
80-
'-p', $promptContent
76+
'-p', '-'
8177
)
8278

83-
& claude @claudeArgs 2>&1 | ForEach-Object {
79+
$promptContent | & claude @claudeArgs 2>&1 | ForEach-Object {
8480
$line = $PSItem
8581
try {
8682
$obj = $line | ConvertFrom-Json -ErrorAction Stop
@@ -140,4 +136,4 @@ $final = Get-TrackerStatus
140136
Write-Host ("`n=== $DomainUpper Final: {0}/{1} done ===" -f $final.Done, $final.Total) -ForegroundColor Cyan
141137
if ($final.Pending -gt 0) {
142138
Write-Host "[WARN] $($final.Pending) commands still pending" -ForegroundColor Yellow
143-
}
139+
}

0 commit comments

Comments
 (0)