< Summary - Kestrun — Combined Coverage

Information
Class: Private.Assembly.Add-KrAspNetCoreType
Assembly: Kestrun.PowerShell.Private
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Private/Assembly/Add-KrAspNetCoreType.ps1
Tag: Kestrun/Kestrun@eeafbe813231ed23417e7b339e170e307b2c86f9
Line coverage
0%
Covered lines: 0
Uncovered lines: 39
Coverable lines: 39
Total lines: 80
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 09/12/2025 - 13:32:05 Line coverage: 71.4% (25/35) Total lines: 66 Tag: Kestrun/Kestrun@63ea5841fe73fd164406accba17a956e8c08357f10/13/2025 - 16:52:37 Line coverage: 0% (0/35) Total lines: 66 Tag: Kestrun/Kestrun@10d476bee71c71ad215bb8ab59f219887b5b4a5e12/21/2025 - 19:25:34 Line coverage: 0% (0/39) Total lines: 80 Tag: Kestrun/Kestrun@63eee3e6ff7662a7eb5bb3603d667daccb809f2d01/21/2026 - 17:07:46 Line coverage: 76.9% (30/39) Total lines: 80 Tag: Kestrun/Kestrun@3f6f61710c7ef7d5953cab578fe699c1e5e01a3602/05/2026 - 00:28:18 Line coverage: 0% (0/39) Total lines: 80 Tag: Kestrun/Kestrun@d9261bd752e45afa789d10bc0c82b7d5724d9589

Coverage delta

Coverage delta 77 -77

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Private/Assembly/Add-KrAspNetCoreType.ps1

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Loads required ASP.NET Core assemblies for PowerShell usage.
 4    .PARAMETER Version
 5        The .NET version to target (e.g. net8, net9, net10).
 6#>
 7function Add-KrAspNetCoreType {
 8    [CmdletBinding()]
 9    [OutputType([bool])]
 10    param (
 11        [Parameter()]
 12        [ValidateSet('net8.0', 'net9.0', 'net10.0')]
 13        [string]$Version = 'net8.0'
 14    )
 015    $versionNumber = $Version -replace 'net(\d+).*', '$1'
 016    $dotnetPath = (Get-Command -Name 'dotnet' -ErrorAction Stop).Source
 017    $realDotnetPath = (Get-Item $dotnetPath).Target
 018    if (-not $realDotnetPath) { $realDotnetPath = $dotnetPath }elseif ($realDotnetPath -notmatch '^/') {
 19        # If the target is a relative path, resolve it from the parent of $dotnetPath (e.g. symlink in same folder)
 020        $realDotnetPath = Join-Path -Path (Split-Path -Path $dotnetPath -Parent) -ChildPath $realDotnetPath
 021        $realDotnetPath = [System.IO.Path]::GetFullPath($realDotnetPath)
 22    }
 023    $dotnetDir = Split-Path -Path $realDotnetPath -Parent
 024    if (-not $dotnetDir) {
 025        throw 'Could not determine the path to the dotnet executable.'
 26    }
 027    $baseDir = Join-Path -Path $dotnetDir -ChildPath 'shared\Microsoft.AspNetCore.App'
 028    if (-not (Test-Path -Path $baseDir -PathType Container)) {
 029        throw "ASP.NET Core shared framework not found at $baseDir."
 30    }
 031    $versionDirs = Get-ChildItem -Path $baseDir -Directory | Where-Object { $_.Name -like "$($versionNumber).*" } | Sort
 32
 33    # Try each version directory until we find one with all required assemblies
 034    $verDir = $versionDirs | Select-Object -First 1
 035    if (-not $verDir) {
 036        Write-Error "Could not find ASP.NET Core assemblies for version $Version in $baseDir."
 037        Write-Warning "Please download the Runtime $Version from https://dotnet.microsoft.com/en-us/download/dotnet/$ver
 38
 039        throw "Microsoft.AspNetCore.App version $Version not found in $baseDir."
 40    }
 41
 42    # Collect required assemblies
 043    $assemblies = @()
 44
 045    Get-ChildItem -Path $verDir.FullName -Filter '*.dll' |
 046        Where-Object {
 047            $_.Name -like 'Microsoft.*.dll' -or
 48            $_.Name -eq 'System.IO.Pipelines.dll'
 049        } | ForEach-Object {
 050            if ($assemblies -notcontains $_.Name) {
 051                $assemblies += $_.Name
 52            }
 53        }
 54
 055    Write-Verbose "Collected assemblies: $($assemblies -join ', ')"
 56
 57    # Check if all required assemblies are present
 058    $allFound = $true
 059    foreach ($asm in $assemblies) {
 060        $asmPath = Join-Path -Path $verDir.FullName -ChildPath $asm
 061        if (-not (Test-Path -Path $asmPath)) {
 062            Write-Verbose "Assembly $asm not found in $($verDir.FullName)"
 063            $allFound = $false
 64            break
 65        }
 66    }
 67
 068    if (-not $allFound) { return $false }
 69
 70    # Load all assemblies
 071    $result = $true
 072    foreach ($asm in $assemblies) {
 073        $asmPath = Join-Path -Path $verDir.FullName -ChildPath $asm
 074        $result = $result -and (Assert-KrAssemblyLoaded -AssemblyPath $asmPath)
 75    }
 76
 077    Write-Verbose "Loaded ASP.NET Core assemblies from $($verDir.FullName)"
 078    return $result
 79}
 80

Methods/Properties

Add-KrAspNetCoreType()