This might be the old question but I will write what worked for me. As Mike tried to do I also used the startup task and powershell script to install .net core on the Azure Batch Node.
I verified, the dot net core does gets installed but at different location, and the path is not exported to environment variables but only used by the current process. This is the reason it actually does not work
So I made 2 changes in above Start Task code
- Provide InstallDir where I want to Install .net core
- Export the Path to Environment Variables.
Refer to the code below which made this thing work
powershell "if(!([Environment]::GetEnvironmentVariable('Path', 'Machine') -split ';' -contains \"$Env:ProgramFiles\dotnet\\\")) {[Environment]::SetEnvironmentVariable('Path', \"$([Environment]::GetEnvironmentVariable('Path', 'Machine'));$Env:ProgramFiles\dotnet\\\",'Machine');}"
powershell -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -useb 'https://dot.net/v1/dotnet-install.ps1'))) -Channel LTS -InstallDir \"$Env:ProgramFiles\dotnet\\\""
After this, I am able to run my .net core code on the Machine