title: How to install and use dotnet core tool (CLI) in Azure Pipelines (VSTS) Build Task?
body: <p>I want to create custom build task, that would do invoke dotnet core CLI tool. I've used <a href="https://github.com/Microsoft/vsts-task-lib/tree/master/node" rel="nofollow noreferrer">VSTS DevOps Task SDK/node</a> to get or install the tool:</p>
  
  <pre><code>import tl = require('vsts-task-lib/task');
  
  async function getLibmanTool() {
      let libmanExePath = tl.which('libman');
      if (!libmanExePath){
          console.log("Libman CLI not found. Installing..")
          var dotnet = tl.tool(tl.which('dotnet', true));
          await dotnet.arg(['tool', 'install', '-g', 'Microsoft.Web.LibraryManager.Cli']).exec();
      }
      libmanExePath = tl.which('libman', true); //this line throws, see output
      return tl.tool(libmanExePath);
  }
  </code></pre>
  
  <p>However, when I use the tool in Build Pipeline:
  <a href="https://i.stack.imgur.com/mOU4Z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mOU4Z.png" alt="enter image description here"></a></p>
  
  <p>I'm getting following error:</p>
  
  <pre><code>Libman CLI not found. Installing..
  [command]C:\hostedtoolcache\windows\dncs\2.1.105\x64\dotnet.exe tool install -g Microsoft.Web.LibraryManager.Cli
  Since you just installed the .NET Core SDK, you will need to reopen the Command Prompt window before running the tool you installed.
  You can invoke the tool using the following command: libman
  Tool 'microsoft.web.librarymanager.cli' (version '1.0.163') was successfully installed.
  ##[error]Unable to locate executable file: 'libman'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.
  </code></pre>
  
  <p>It look like when I install .NET Core SDK in the pipleline, it is unable to find the dotnet tool</p>
  
  <h2>Question:</h2>
  
  <p>How do I install and then safely use the dotnet core tool? Is the any way to workaround following?</p>
  
  <blockquote>
    <p>Since you just installed the .NET Core SDK, you will need to reopen the Command Prompt window before running the tool you installed</p>
  </blockquote>