Skip to content

Commit d68cd88

Browse files
committed
dotnet_home: more robust
1 parent ca2a4f4 commit d68cd88

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

+stdlib/dotnet_api.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
try
66
v = System.Environment.Version.Major;
77
catch
8+
% not empty because that breaks less-than logic
89
v = -1;
910
end
1011

+stdlib/dotnet_home.m

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
%% DOTNET_HOME give .NET RuntimeLocation
22

33
function h = dotnet_home()
4-
try
5-
h = dotnetenv().RuntimeLocation;
6-
catch
7-
h = "";
4+
5+
h = string.empty;
6+
7+
try %#ok<TRYNC>
8+
9+
if NET.isNETSupported
10+
% need to call this at least once or dotnetenv() is empty
11+
12+
h = dotnetenv().RuntimeLocation;
13+
end
14+
815
end
16+
917
end

0 commit comments

Comments
 (0)