Publish using "Produce single file" - Unhandled exception. System.ArgumentException: The path is empty. (Parameter 'path')
See original GitHub issueDescription
PuppeteerSharp 9.0.0 introduced a bug that will cause to fail the parameterless ctor of BrowserFetcher when using in some published exe with “Produce single file” enabled.
Complete minimal example reproducing the issue
- Get any example code that uses the parameterless ctor of BrowserFetcher and put it into a console application (.net6 and .net7 are known to cause the issue)
- Publish project with option “Produce single file” enabled.
- Run the published exe
- Minimal repro
Expected behavior:
Running without exception, like PuppeteerSharp 8.
Actual behavior:
Unhandled exception. System.ArgumentException: The path is empty. (Parameter 'path')
at System.IO.Path.GetFullPath(String path)
at System.IO.FileInfo..ctor(String originalPath, String fullPath, String fileName, Boolean isNormalized)
at System.IO.FileInfo..ctor(String fileName)
at PuppeteerSharp.BrowserFetcher.GetExecutablePath() in C:\projects\puppeteer-sharp\lib\PuppeteerSharp\BrowserFetcher.cs:line 354
at PuppeteerSharp.BrowserFetcher..ctor() in C:\projects\puppeteer-sharp\lib\PuppeteerSharp\BrowserFetcher.cs:line 53
at Program.<Main>$(String[] args) in C:\source\repos\PuppeteerSharpMinimalRepro\PuppeteerSharpMinimalRepro\Program.cs:line 5
at Program.<Main>(String[] args)
Versions
- Which version of PuppeteerSharp are you using? 9.0.0 and 9.0.1
- Which .NET runtime and version are you targeting? .net6 and .net7
Additional Information - Workarround - Use overloads of the BrowserFetcher ctor.
var options = new BrowserFetcherOptions();
options.Path = Path.GetTempPath();
using var browserFetcher = new BrowserFetcher(options);
var revisionInfo = await browserFetcher.DownloadAsync();
await using var browser = await Puppeteer.LaunchAsync(new LaunchOptions { Headless = true, ExecutablePath = revisionInfo.ExecutablePath });
await using var page = await browser.NewPageAsync();
await page.GoToAsync("http://www.google.com");
await page.ScreenshotAsync("google.jpg");
Issue Analytics
- State:
- Created 8 months ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Paths.GetExecutablePath fails in .NET 6 single-file ...
Unhandled exception : System.ArgumentException: The path is empty. (Parameter 'path') at System.IO.Path.GetFullPath(String path) in System.
Read more >XAF 21.2.3 System.ArgumentException: Empty path name ...
Location property returns an empty string in your case. This may be caused by the "Produce single file" publish option.
Read more >Why is this producing an "Empty Path Name Is Not Legal" ...
1 Answer 1 ... The call stack of the exception shows that you are looking the completely wrong corner for this problem. You...
Read more >C# System.ArgumentException: "Empty path name is not ...
Based on your findings in the debug. If FileName is blank, you will get this error. You need to input a filename. You...
Read more >IL3000: Avoid accessing Assembly file path when ...
Cause. When publishing as a single-file (for example, by setting the PublishSingleFile property in a project to true), calling the Assembly.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yeah. We should fix this.
See https://learn.microsoft.com/en-us/dotnet/core/deploying/single-file/overview?tabs=cli#api-incompatibility for list of known
APIs
that are incompatible withSingleFile
builds.