File tree Expand file tree Collapse file tree 1 file changed +18
-5
lines changed
src/WeihanLi.Common/Helpers Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,24 @@ public static LibraryInfo GetLibraryInfo(Assembly assembly)
63
63
/// </summary>
64
64
public static string ? GetDotnetPath ( )
65
65
{
66
+ var environmentOverride = Environment . GetEnvironmentVariable ( "DOTNET_ROOT" ) ;
67
+ if ( ! string . IsNullOrEmpty ( environmentOverride ) && Directory . Exists ( environmentOverride ) )
68
+ {
69
+ var execFileName =
70
+ #if NET6_0_OR_GREATER
71
+ OperatingSystem . IsWindows ( )
72
+ #else
73
+ RuntimeInformation . IsOSPlatform ( OSPlatform . Windows )
74
+ #endif
75
+ ? "dotnet.exe"
76
+ : "dotnet"
77
+ ;
78
+ var dotnetExePath = Path . Combine ( environmentOverride , execFileName ) ;
79
+ if ( File . Exists ( dotnetExePath ) )
80
+ return dotnetExePath ;
81
+
82
+ throw new InvalidOperationException ( $ "dotnet executable file not found under specified DOTNET_ROOT { environmentOverride } ") ;
83
+ }
66
84
return ResolvePath ( "dotnet" ) ;
67
85
}
68
86
@@ -73,11 +91,6 @@ public static string GetDotnetDirectory()
73
91
{
74
92
return environmentOverride ;
75
93
}
76
- environmentOverride = Environment . GetEnvironmentVariable ( "DOTNET_ROOT" ) ;
77
- if ( ! string . IsNullOrEmpty ( environmentOverride ) )
78
- {
79
- return environmentOverride ;
80
- }
81
94
82
95
var dotnetExe = GetDotnetPath ( ) ;
83
96
You can’t perform that action at this time.
0 commit comments