I am trying to use Playwright to run within an ASP.NET Core 8 web app. It installed the browsers under the user profile.
Everything works in development. When I deploy the web app for release, it throws the error:
Microsoft.Playwright.PlaywrightException: Executable doesn't exist
at C:\Windows\system32\config\systemprofile\AppData\Local\ms-playwright\chromium_headless_shell-1161\chrome-win\headless_shell.exe
I know I can just copy the files over to this location, but would rather not. How can I get it to look for a custom folder?
I am using .NET 8.
Playwright looks for its binaries in %LOCALAPPDATA%\ms-playwright
.
An IIS worker that starts under systemprofile
has no %LOCALAPPDATA%
, so it tries
C:\Windows\system32\config\systemprofile\AppData\Local\ms-playwright\…
and finds nothing (see https://playwright.dev/dotnet/docs/browsers).
Two ways to fix it:
Load a user profile
IIS Manager → Application Pools → your pool
, Advanced Settings → set Load User Profile = True
Then run playwright install
once while logged in as the same identity. The profile now contains the browsers and Playwright starts fine.
Use a shared cache
D:\Playwright\Browsers
.$Env:PLAYWRIGHT_BROWSERS_PATH='D:\Playwright\Browsers'; pwsh .\playwright.ps1 install --with-deps
web.config
or Environment.SetEnvironmentVariable
in Program.cs
).
From then on Playwright will launch from that folder in every environment.