Gitlab ci for react-dotnet template

hello there! Iam trying to build my new react-dotnet template (https://docs.microsoft.com/en-us/aspnet/core/client-side/spa/react?view=aspnetcore-2.1&tabs=visual-studio) application.
here is my .gitlab-ci.yml:

stages:
  - build
before_script:
  - dotnet restore
build:
image: microsoft/dotnet:2.2-sdk
stage: build
script:
    - dotnet build

and i got an error:

Running with gitlab-runner 11.1.0 (081978aa)
  on docker-alpine-frontend 5b8b7a58
Using Docker executor with image microsoft/dotnet:2.2-sdk ...
Pulling docker image microsoft/dotnet:2.2-sdk ...
Using docker image sha256:c361edb2668cccee82d732db084d41f409dd305e59bcfeb312519bfb3e42880a for microsoft/dotnet:2.2-sdk ...
Running on runner-5b8b7a58-project-134-concurrent-0 via 0b190a23067d...
Fetching changes...
HEAD is now at 4c00cca Update .gitlab-ci.yml
From http://<project name>
   4c00cca..bb8175c  master     -> origin/master
Checking out bb8175cf as master...
Skipping Git submodules setup
$ dotnet restore
  Restoring packages for /builds/<project name>.csproj...
  Installing System.Runtime.CompilerServices.Unsafe 4.4.0.
  <project name>
  Installing Serilog.Formatting.Compact 1.0.0.
  Generating MSBuild file /builds/<project name>.csproj.nuget.g.props.
  Generating MSBuild file /builds/<project name>.csproj.nuget.g.targets.
  Restore completed in 8.22 sec for /builds/<project name>.csproj.
$ dotnet build
Microsoft (R) Build Engine version 15.9.8-preview+g0a5001fc4d for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 99.29 ms for /builds/<project name>.csproj.
/usr/share/dotnet/sdk/2.2.100-preview2-009404/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.RuntimeIdentifierInference.targets(143,5): message NETSDK1057: You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview [/builds/<project name>.csproj]
BL/<project file>.cs(20,23): warning CS0169: The field '...' is never used [/builds/<project name>.csproj]
  l<project file> -> /builds/<project name>/bin/Debug/netcoreapp2.2/l<project file>.dll
  l<project file> -> /builds/<project name>/bin/Debug/netcoreapp2.2/l<project file>.Views.dll
  /bin/sh: 2: /tmp/tmpf81d00773aeb4df0aec7d0e79c1b8484.exec.cmd: node: not found
/builds/<project name>.csproj(30,5): warning MSB3073: The command "node --version" exited with code 127.
/builds/<project name>.csproj(33,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.

Build FAILED.

BL/<project file>.cs(20,23): warning CS0169: The field '...' is never used [/builds/<project name>.csproj]
/builds/<project name>.csproj(30,5): warning MSB3073: The command "node --version" exited with code 127.
/builds/<project name>.csproj(33,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.
    2 Warning(s)
    1 Error(s)

Time Elapsed 00:00:06.26
ERROR: Job failed: exit code 1

This line in the log would seem to indicate that the node command is not available, so perhaps NodeJS is not in the microsoft/dotnet:2.2-sdk image and you need to explicitly install it?

1 Like

you have to install Node.js and react before the build

image: microsoft/dotnet:latest

stages:
    - build
    - test

before_script:
    - "dotnet --info"
    - "curl -sL https://deb.nodesource.com/setup_10.x | bash -"
    - "apt-get install -y nodejs"
    - "npm install -g react"

build:
    stage: build
    script:
        - "dotnet build"
    artifacts:
      paths:
        - bin/

test:
    stage: test
    script: 
        - "dotnet test"
1 Like

thanks! I was missing this part, too :slight_smile: