Installing node while using .net core image

Hi there, I'm trying to run a job to run the tests project in my .net core/react application. The issue I'm running into is: 

/bin/sh: 2: /tmp/MSBuildTemproot/tmp3f249356b24e4253937d15f466194951.exec.cmd: node: not found
04:39:00
/mnt/space/work/Slowx-CRM/SlowxCRM.Application/SlowxCRM.Application.csproj(42,5): warning MSB3073: The command "node --version" exited with code 127.
04:39:00
/mnt/space/work/Slowx-CRM/SlowxCRM.Application/SlowxCRM.Application.csproj(45,5): error : Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE.
 
My job code is: 
 
job("Run tests"){
container(image = "mcr.microsoft.com/dotnet/sdk:6.0"){
shellScript {
content = """
dotnet test ./SlowxCRM.Tests/
"""
}
}
}
 
My question is, how do I install node into this container in order to run my tests?
0
1 comment

Hello Robert,

Thanks for the question! In fact, there are 2 options here:

1. Build your custom image based on the one you currently use (mcr.microsoft.com/dotnet/sdk:6.0) and preinstall node package. This article might come in handy.
2. Install node package during the job execution directly from shellScript. It should look like this:

job("Test job") {
    container(displayName = "Install node and run tests", image = "mcr.microsoft.com/dotnet/sdk:6.0") {
        shellScript {
            content = """
                apt update && apt install nodejs -y
                node --version
                dotnet test ./SlowxCRM.Tests/
            """
        }
    }
}
0

Please sign in to leave a comment.