Functions/Install-PWBrowsers.ps1
function Install-PWBrowsers { <# .SYNOPSIS Installs Playwright browsers. .DESCRIPTION The `Install-PWBrowsers` function installs Playwright browsers. It uses the .NET CLI to create a new console application, add the Microsoft.Playwright package, and build the application. It then installs the Playwright browsers using the generated console application. Once the browsers are installed, the console application is removed. .EXAMPLE Install-PWBrowsers Demonstrates installing Playwright browsers. #> [CmdletBinding()] param() if (-not (Get-Command 'dotnet' -ErrorAction SilentlyContinue)) { throw 'The .NET CLI is required to install Playwright browsers.' } Push-Location -Path $PSScriptRoot $consoleLocation = Join-Path -Path $PSScriptRoot -ChildPath 'PlaywrightConfiguration' dotnet new console -n 'PlaywrightConfiguration' Set-Location -Path $consoleLocation dotnet add package Microsoft.Playwright dotnet build $netVersionLocations = Get-ChildItem -Path (Join-Path -Path $consoleLocation -ChildPath 'bin\Debug') -Directory & (Join-Path -Path $netVersionLocations -ChildPath 'playwright.ps1' -Resolve) install Start-Sleep -Seconds 5 Remove-Item -Recurse -Force $consoleLocation Pop-Location } |