C#C
C#12mo ago
Emily-TTG

Resolve `dotnet` executable path programmatically

Trying to get NuGet packages loading correctly under a hosted env. -- so I need to grab the NuGet package dir. But doing so programmatically itself seems to require a NuGet package so I'm trying to just grab the output from
dotnet nuget locals global-packages --list
instead.

However I want to try and support a situation where the executing
dotnet
may not be the one on the
PATH
, or no
dotnet
is present on the
PATH
at all -- so I'd like to grab the
dotnet
executable which is running the current program. I couldn't find a reliable way to do this without some janky solution like getting the process
argv
with native APIs so I thought I'd ask here.

Thanks in advance!
Was this page helpful?