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
2222 {
2323 get
2424 {
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
2529 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
2644 if ( string . IsNullOrEmpty ( path ) )
2745 {
46+ // no
2847 path = string . IsNullOrEmpty ( ToolPath ) ? "" : ToolPath ;
48+ path = Path . Combine ( path , ToolExe ) ;
2949 }
3050
3151 return path ;
3252 }
3353 }
3454
35- protected override string GenerateFullPathToTool ( ) => Path . Combine ( DotNetPath , ToolExe ) ;
55+ protected override string GenerateFullPathToTool ( ) => DotNetPath ;
3656
3757 /// <summary>
3858 /// 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