@@ -32,33 +32,34 @@ public async Task GeneratePdf()
3232 Log . WriteInfo ( "Test Log" , $ "OS: { os } ") ;
3333
3434 string path = "" ;
35- BrowserFetcher ? browserFetcher = default ;
35+ Platform platform = Platform . Unknown ;
3636
3737 switch ( os . Platform )
3838 {
3939 case PlatformID . Win32NT :
40- browserFetcher = new ( ) ;
40+ platform = Platform . Win32 ;
4141 break ;
4242 case PlatformID . Unix :
4343 path = ChromeBinPathLinux ;
44- browserFetcher = new ( new BrowserFetcherOptions { Path = path , Platform = Platform . Linux , Browser = SupportedBrowser . ChromeHeadlessShell } ) ;
44+ platform = Platform . Linux ;
4545 break ;
4646 default :
4747 break ;
4848 }
4949
50- foreach ( var browser_installed in browserFetcher . GetInstalledBrowsers ( ) )
50+ InstalledBrowser ? installedBrowser = new BrowserFetcher ( new BrowserFetcherOptions ( ) { Platform = platform , Browser = SupportedBrowser . Chrome , Path = path } ) . GetInstalledBrowsers ( )
51+ . FirstOrDefault ( _ => _ . Platform == platform && _ . Browser == SupportedBrowser . Chrome ) ;
52+
53+ foreach ( var brw in new BrowserFetcher ( new BrowserFetcherOptions ( ) { Platform = platform , Browser = SupportedBrowser . Chrome , Path = path } ) . GetInstalledBrowsers ( ) )
5154 {
52- Log . WriteInfo ( "Test Log" , $ "Browser: { browser_installed . GetExecutablePath ( ) } ") ;
55+ Log . WriteInfo ( "Test Log" , $ "Browser: { brw . GetExecutablePath ( ) } ") ;
5356 }
5457
55- InstalledBrowser ? brw = browserFetcher . GetInstalledBrowsers ( ) . FirstOrDefault ( _ => _ . Platform == Platform . Linux && _ . Browser == SupportedBrowser . ChromeHeadlessShell ) ?? await browserFetcher . DownloadAsync ( BrowserTag . Latest ) ;
56-
57- Log . WriteInfo ( "Test Log" , $ "Browser Path: { brw . GetExecutablePath ( ) } ") ;
58+ Log . WriteInfo ( "Test Log" , $ "Browser Path: { installedBrowser . GetExecutablePath ( ) } ") ;
5859
5960 using IBrowser ? browser = await Puppeteer . LaunchAsync ( new LaunchOptions
6061 {
61- ExecutablePath = brw . GetExecutablePath ( ) ,
62+ ExecutablePath = installedBrowser . GetExecutablePath ( ) ,
6263 Headless = true
6364 } ) ;
6465
0 commit comments