mirror of
https://github.com/GoodOlClint/PSProxmoxVE.git
synced 2026-07-26 07:58:14 +00:00
94424367bf
F058 (critical): Replace while(true) infinite-loop task polling with TaskService.WaitForTask in 5 container snapshot and storage cmdlets. F073+F047 (high): Migrate net9.0 → net10.0 across both source .csproj files, build.yml, publish.yml, and test helper. F071 (medium): Add Uri.EscapeDataString() to all inline URL path segments in ~16 cmdlets that bypass service classes (D003). F062+F063 (medium): Add ConfirmImpact.High to Restart-PveContainer and Suspend-PveContainer (D006). F075 (medium): Generate markdown help docs for 89 cmdlets that were missing documentation (170 total, up from 81). F072 (low): Remove unused System.Text.Json dependency from Core.csproj. F074 (low): Raise publish smoke-test threshold from 60 to 150. F065 (low): Add .github/ISSUE_TEMPLATE/config.yml. F066 (low): Add CODEOWNERS. Also fix _TestHelper.ps1 net9.0 → net10.0 framework reference. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
60 lines
2.2 KiB
PowerShell
60 lines
2.2 KiB
PowerShell
<#
|
|
.SYNOPSIS
|
|
Shared module-loading helper for Pester tests.
|
|
Dot-source this file inside BeforeAll to import PSProxmoxVE reliably
|
|
in both local-dev and CI environments.
|
|
#>
|
|
|
|
# If the module is already loaded, nothing to do.
|
|
if (Get-Module -Name PSProxmoxVE) { return }
|
|
|
|
# Ensure DOTNET_ROOT doesn't override PS's bundled runtime (CI sets this
|
|
# via setup-dotnet and it can break binary module assembly resolution).
|
|
if ($env:DOTNET_ROOT) {
|
|
$env:DOTNET_ROOT = $null
|
|
$env:DOTNET_MULTILEVEL_LOOKUP = $null
|
|
}
|
|
|
|
# 1. Try importing by module name (works in CI where the module is
|
|
# installed to a PSModulePath location via dotnet publish + copy).
|
|
$available = Get-Module PSProxmoxVE -ListAvailable -ErrorAction SilentlyContinue
|
|
if ($available) {
|
|
Import-Module PSProxmoxVE -Force -ErrorAction Stop
|
|
return
|
|
}
|
|
|
|
# 2. Discover the module manifest (.psd1) from the local source tree.
|
|
# Loading via manifest ensures PS handles assembly resolution correctly.
|
|
# Prefer the framework that matches the running PowerShell edition.
|
|
$repoRoot = Resolve-Path (Join-Path $PSScriptRoot '../..')
|
|
$moduleRoot = Join-Path $repoRoot 'src/PSProxmoxVE'
|
|
|
|
if ($PSVersionTable.PSEdition -eq 'Core') {
|
|
$frameworks = @('netstandard2.0', 'net10.0', 'net48')
|
|
}
|
|
else {
|
|
$frameworks = @('net48', 'netstandard2.0', 'net10.0')
|
|
}
|
|
|
|
$searchPaths = foreach ($fw in $frameworks) {
|
|
# Publish output (has all dependencies co-located)
|
|
Join-Path $repoRoot "publish/$fw/PSProxmoxVE.psd1"
|
|
# Build output
|
|
Join-Path $moduleRoot "bin/Debug/$fw/PSProxmoxVE.psd1"
|
|
Join-Path $moduleRoot "bin/Release/$fw/PSProxmoxVE.psd1"
|
|
}
|
|
|
|
$moduleManifest = $searchPaths | Where-Object { Test-Path $_ } | Select-Object -First 1
|
|
|
|
if ($null -eq $moduleManifest) {
|
|
throw "PSProxmoxVE module not found. Build the project before running Pester tests."
|
|
}
|
|
|
|
# Remove files that cause .NET assembly resolution conflicts when loading
|
|
# a binary module inside PowerShell's own runtime.
|
|
$moduleDir = Split-Path $moduleManifest
|
|
Get-ChildItem $moduleDir -Filter '*.deps.json' -ErrorAction SilentlyContinue | Remove-Item -Force
|
|
Get-ChildItem $moduleDir -Filter '*.runtimeconfig.json' -ErrorAction SilentlyContinue | Remove-Item -Force
|
|
|
|
Import-Module $moduleManifest -Force -ErrorAction Stop
|