Skip to content

Commit 95beee9

Browse files
authored
Improve DownloadFetcher executable path (#2074)
closes #2073
1 parent 087228c commit 95beee9

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

lib/PuppeteerSharp/BrowserFetcher.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,27 @@ internal static string GetExecutablePath()
350350
DirectoryInfo assemblyDirectory = new(AppContext.BaseDirectory);
351351
if (!assemblyDirectory.Exists || !File.Exists(Path.Combine(assemblyDirectory.FullName, "PuppeteerSharp.dll")))
352352
{
353-
var assemblyLocation = typeof(Puppeteer).Assembly.Location;
353+
string assemblyLocation;
354+
var assembly = typeof(Puppeteer).Assembly;
355+
#pragma warning disable SYSLIB0012 // 'Assembly.CodeBase' is obsolete: 'Assembly.CodeBase and Assembly.EscapedCodeBase are only included for .NET Framework compatibility.
356+
if (Uri.TryCreate(assembly.CodeBase, UriKind.Absolute, out var codeBase) && codeBase.IsFile)
357+
#pragma warning restore SYSLIB0012 // 'Assembly.CodeBase' is obsolete: 'Assembly.CodeBase and Assembly.EscapedCodeBase are only included for .NET Framework compatibility.
358+
{
359+
assemblyLocation = codeBase.LocalPath;
360+
}
361+
else
362+
{
363+
assemblyLocation = assembly.Location;
364+
}
365+
354366
assemblyDirectory = new FileInfo(assemblyLocation).Directory;
355367
}
356368

369+
if (!assemblyDirectory.Exists || !File.Exists(Path.Combine(assemblyDirectory.FullName, "PuppeteerSharp.dll")))
370+
{
371+
assemblyDirectory = new DirectoryInfo(Directory.GetCurrentDirectory());
372+
}
373+
357374
return assemblyDirectory.FullName;
358375
}
359376

lib/PuppeteerSharp/PuppeteerSharp.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
<Description>Headless Browser .NET API</Description>
1414
<PackageId>PuppeteerSharp</PackageId>
1515
<PackageReleaseNotes></PackageReleaseNotes>
16-
<PackageVersion>9.0.1</PackageVersion>
17-
<ReleaseVersion>9.0.1</ReleaseVersion>
18-
<AssemblyVersion>9.0.0.1</AssemblyVersion>
19-
<FileVersion>9.0.0.1</FileVersion>
16+
<PackageVersion>9.0.2</PackageVersion>
17+
<ReleaseVersion>9.0.2</ReleaseVersion>
18+
<AssemblyVersion>9.0.2.0</AssemblyVersion>
19+
<FileVersion>9.0.2.0</FileVersion>
2020
<SynchReleaseVersion>false</SynchReleaseVersion>
2121
<StyleCopTreatErrorsAsWarnings>false</StyleCopTreatErrorsAsWarnings>
2222
<CodeAnalysisRuleSet>../PuppeteerSharp.ruleset</CodeAnalysisRuleSet>

0 commit comments

Comments
 (0)