File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
src/Containers/Microsoft.NET.Build.Containers/Tasks Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -22,17 +22,37 @@ private string DotNetPath
22
22
{
23
23
get
24
24
{
25
+ // DOTNET_HOST_PATH, if set, is the full path to the dotnet host executable.
26
+ // However, not all environments/scenarios set it correctly - some set it to just the directory.
27
+
28
+ // this is the expected correct case - DOTNET_HOST_PATH is set to the full path of the dotnet host executable
25
29
string path = Environment . GetEnvironmentVariable ( "DOTNET_HOST_PATH" ) ?? "" ;
30
+ if ( Path . IsPathRooted ( path ) && File . Exists ( path ) )
31
+ {
32
+ return path ;
33
+ }
34
+ // some environments set it to just the directory, so we need to check that too
35
+ if ( Path . IsPathRooted ( path ) && Directory . Exists ( path ) )
36
+ {
37
+ path = Path . Combine ( path , ToolExe ) ;
38
+ if ( File . Exists ( path ) )
39
+ {
40
+ return path ;
41
+ }
42
+ }
43
+ // last-chance fallback - use the ToolPath and ToolExe properties to try to synthesize the path
26
44
if ( string . IsNullOrEmpty ( path ) )
27
45
{
46
+ // no
28
47
path = string . IsNullOrEmpty ( ToolPath ) ? "" : ToolPath ;
48
+ path = Path . Combine ( path , ToolExe ) ;
29
49
}
30
50
31
51
return path ;
32
52
}
33
53
}
34
54
35
- protected override string GenerateFullPathToTool ( ) => Path . Combine ( DotNetPath , ToolExe ) ;
55
+ protected override string GenerateFullPathToTool ( ) => DotNetPath ;
36
56
37
57
/// <summary>
38
58
/// Workaround to avoid storing user/pass into the EnvironmentVariables property, which gets logged by the task.
You can’t perform that action at this time.
0 commit comments