From 7768b44eb78800321d41271c89d0f1a8a5f53f00 Mon Sep 17 00:00:00 2001 From: Breederveld <40824795+Breederveld@users.noreply.github.com> Date: Tue, 18 Feb 2020 02:56:31 +0100 Subject: [PATCH] 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. --- src/core/dotnet-tool.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/dotnet-tool.ts b/src/core/dotnet-tool.ts index 1aed0fb..c7b4175 100644 --- a/src/core/dotnet-tool.ts +++ b/src/core/dotnet-tool.ts @@ -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); } -} \ No newline at end of file +}