You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: bootstrap NuGet lazily only when a Nuget/PSGalleryNuget dep is used (#175)
## Summary
Fixes#117.
PSDepend was unconditionally downloading `nuget.exe` at module load time
via `BootStrap-Nuget` in `PSDepend.psm1`, even when no `Nuget` or
`PSGalleryNuget` dependencies were declared. Users relying purely on
`PSGalleryModule` (or any other type) had no way to suppress this
network call.
- Remove the eager `BootStrap-Nuget` call from `PSDepend.psm1`
- Move it into `Nuget.ps1` and `PSGalleryNuget.ps1` so it only runs when
one of those dependency types is actually invoked
- Wrap the call in `Test-PlatformSupport` (matching the original guard)
so bootstrap is skipped on platforms where `nuget.exe` isn't applicable
- Add a missing `return` after `Write-Error` in both scripts —
previously execution would continue into the `nuget install` invocation
even after the error
## Test plan
- [x] `Nuget.Type.Tests.ps1` — new `NuGet bootstrap` context: verifies
`BootStrap-Nuget` is called when `nuget.exe` is missing on a supported
platform, not called on unsupported platforms, and that
`Invoke-ExternalCommand` is never reached when nuget remains unavailable
after bootstrap
- [x] `PSGalleryNuget.Type.Tests.ps1` — same three cases for the
`PSGalleryNuget` script
- [x] All 12 tests pass (`Passed: 12 | Failed: 0`)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Signed-off-by: Gilbert Sanchez <me@gilbertsanchez.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Write-Error"Nuget requires Nuget.exe. Ensure this is in your path, or explicitly specified in $ModuleRoot\PSDepend.Config's NugetPath. Skipping [$DependencyName]"
Write-Error"Nuget requires Nuget.exe. Ensure this is in your path, or explicitly specified in $ModuleRoot\PSDepend.Config's NugetPath. Skipping [$DependencyName]"
119
+
return
120
+
}
113
121
}
114
122
115
123
Write-Verbose-Message "Getting dependency [$DependencyName] from Nuget source [$Source]"
Write-Error"PSGalleryNuget requires Nuget.exe. Ensure this is in your path, or explicitly specified in $ModuleRoot\PSDepend.Config's NugetPath. Skipping [$DependencyName]"
Write-Error"PSGalleryNuget requires Nuget.exe. Ensure this is in your path, or explicitly specified in $ModuleRoot\PSDepend.Config's NugetPath. Skipping [$DependencyName]"
107
+
return
108
+
}
101
109
}
102
110
103
111
Write-Verbose-Message "Getting dependency [$name] from Nuget source [$Source]"
0 commit comments