< Summary - Kestrun — Combined Coverage

Information
Class: Public.Helper.Set-KrEnvironment
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Helper/Set-KrEnvironment.ps1
Tag: Kestrun/Kestrun@ca54e35c77799b76774b3805b6f075cdbc0c5fbe
Line coverage
80%
Covered lines: 4
Uncovered lines: 1
Coverable lines: 5
Total lines: 42
Line coverage: 80%
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 10/13/2025 - 16:52:37 Line coverage: 0% (0/5) Total lines: 42 Tag: Kestrun/Kestrun@10d476bee71c71ad215bb8ab59f219887b5b4a5e01/21/2026 - 17:07:46 Line coverage: 80% (4/5) Total lines: 42 Tag: Kestrun/Kestrun@3f6f61710c7ef7d5953cab578fe699c1e5e01a36

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Helper/Set-KrEnvironment.ps1

#LineLine coverage
 1
 2<#
 3.SYNOPSIS
 4    Sets the Kestrun environment for the current PowerShell session.
 5.DESCRIPTION
 6    Sets the Kestrun environment for the current PowerShell session.
 7    This affects how Kestrun behaves, for example in terms of error handling and logging.
 8.PARAMETER Name
 9    The name of the environment to set. Valid values are 'Development', 'Staging', and 'Production'.
 10.PARAMETER WhatIf
 11    Shows what would happen if the cmdlet runs. The cmdlet is not run.
 12.PARAMETER Confirm
 13    Prompts you for confirmation before running the cmdlet.
 14.OUTPUTS
 15    The name of the currently set environment after applying the change.
 16.EXAMPLE
 17    Set-KrEnvironment -Name 'Development'
 18    Sets the Kestrun environment to 'Development'.
 19    This enables detailed error messages and logging for development purposes.
 20.EXAMPLE
 21    Set-KrEnvironment -Name 'Production'
 22    Sets the Kestrun environment to 'Production'.
 23    This enables optimized settings for a production environment.
 24#>
 25function Set-KrEnvironment {
 26    [KestrunRuntimeApi('Everywhere')]
 27    [CmdletBinding(SupportsShouldProcess)]
 28    [OutputType([string])]
 29    param(
 30        [Parameter(Mandatory)]
 31        [ValidateSet('Auto', 'Development', 'Staging', 'Production')]
 32        [string]$Name
 33    )
 134    if ($PSCmdlet.ShouldProcess('Kestrun Environment', "Set -> $Name")) {
 135        if ($Name -eq 'Auto') {
 136            [Kestrun.Runtime.EnvironmentHelper]::ClearOverride()
 37        } else {
 038            [Kestrun.Runtime.EnvironmentHelper]::SetOverrideName($Name)
 39        }
 140        [Kestrun.Runtime.EnvironmentHelper]::Name
 41    }
 42}

Methods/Properties

Set-KrEnvironment()