Allow DOTNET_ROOT to be based on an actual file

Check if DOTNET_ROOT isn't already set, if not base the value on the location of the actual dotnet file, symlinked or not.
This commit is contained in:
Breederveld
2020-02-18 02:56:31 +01:00
committed by Artur
parent 788800ab1d
commit 7768b44eb7

View File

@@ -94,8 +94,10 @@ export class DotnetTool implements IDotnetTool {
//
this.buildAgent.debug(`toolPath: ${toolPath}`);
if (os.platform() !== "win32") {
const dotnetRoot = path.dirname(fs.readlinkSync(await this.buildAgent.which("dotnet")));
if (os.platform() !== "win32" && !this.buildAgent.getVariable("DOTNET_ROOT")) {
let dotnetPath = await this.buildAgent.which("dotnet");
dotnetPath = fs.readlinkSync(dotnetPath) || dotnetPath;
const dotnetRoot = path.dirname(dotnetPath);
this.buildAgent.exportVariable("DOTNET_ROOT", dotnetRoot);
}
this.buildAgent.addPath(toolPath);
@@ -148,4 +150,4 @@ export class DotnetTool implements IDotnetTool {
return await this.buildAgent.cacheDir(tempDirectory, toolName, version);
}
}
}