mirror of
https://github.com/Smaug123/WoofWare.DotnetRuntimeLocator
synced 2025-10-05 07:18:40 +00:00
Add runtime lookup (#94)
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<SelfContained>true</SelfContained>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@@ -1,6 +1,8 @@
|
||||
namespace Example
|
||||
namespace Example
|
||||
|
||||
open System
|
||||
open System.IO
|
||||
open System.Reflection
|
||||
open WoofWare.DotnetRuntimeLocator
|
||||
|
||||
module Program =
|
||||
@@ -18,4 +20,16 @@ module Program =
|
||||
for f in info.Frameworks do
|
||||
Console.WriteLine $"Framework: %O{f}"
|
||||
|
||||
// Identify the runtime which would execute this DLL
|
||||
let self = Assembly.GetExecutingAssembly().Location
|
||||
let runtimeSearchDirs = DotnetRuntime.SelectForDll self
|
||||
// For example, the System.Text.Json.dll which this DLL would load:
|
||||
runtimeSearchDirs
|
||||
|> Seq.tryPick (fun dir ->
|
||||
let attempt = Path.Combine (dir, "System.Text.Json.dll")
|
||||
if File.Exists attempt then Some attempt else None
|
||||
)
|
||||
|> Option.get
|
||||
|> fun s -> Console.WriteLine $"System.Text.Json location: %s{s}"
|
||||
|
||||
0
|
||||
|
Reference in New Issue
Block a user