Commit 068a97f1 authored by Protocole's avatar Protocole
Browse files

Init .NET Build job

parent 347e06d2
Loading
Loading
Loading
Loading
+51 −0
Original line number Diff line number Diff line
# 🌐 .NET Builder

## Description

Builds a .NET Core project with the different versions available. 
It is using the scripted installation provided from Microsoft, see [here](https://docs.microsoft.com/en-us/dotnet/core/install/linux-alpine#scripted-install).

## How to use it

1. Prepare your project in your repository with its `.csproj` file.
2. Add the corresponding URL to your `.gitlab-ci.yml` file (see [Getting
   started](/use-the-hub)). Example:

    ```yaml
    include:
      - remote: 'https://jobs.go2scale.io/dotnet_build.yml'
    ```

3. If you need to customize the job (stage, variables, ...) 👉 check the [jobs
   customization](/use-the-hub/#jobs-customization)

4. Well done, your job is ready to work ! 😀

## Job details

* Job name: `dotnet_build`
* Docker image: [`alpine:3.12.1`](https://hub.docker.com/_/alpine)
* Default stage: `build`

### Variables

| VARIABLE NAME | DESCRIPTION | DEFAULT VALUE |
|:-|:-|:-
| `DOTNET_OUTPUT` <img width=150/> | Path to the built version in the artifact <img width=175/>| `/build` <img width=100/>|
| `DOTNET_VERSION` | .NET version used to build. You have the choice between multiples versions (see [versions](https://github.com/dotnet/installer#installers-and-binaries)). | `3.1` |
| `DOTNET_VERBOSITY` | Prints more or less logs (*Types available*: `q[uiet]`, `m[inimal]`, `n[ormal]`, `d[etailed]` and `diag[nostic]`) | `minimal` |
| `DOTNET_CONFIG` | Configuration used to build | `Debug` |
| `PROJECT_ROOT` | The location of the .NET project in your repository | `/` |

!!! warning
    Since **version 5.0** of .NET is still in **release-candidate** at this time, the format of `DOTNET_VERSION` is slightly different from just `3.1` or `2.1`. See [Microsoft documentation](https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script#options) (*argument `-Channel`*) to see how to specify this new version.

### Artifacts

When the job is successful, the build of your project is available in an artifact. The artifact is `exposed_as` (see [expose](https://docs.gitlab.com/ee/ci/yaml/#artifactsexpose_as)) `dotNET Build` in your merge request.

!!! warning
    Exposition of artifact doesn't work currently because of [this issue from
    Gitlab](https://gitlab.com/gitlab-org/gitlab/-/issues/37129). As soon as
    the issue will be fixed, exposed artifacts will be available in merge
    requests.
 No newline at end of file
+33 −0
Original line number Diff line number Diff line
# Job from go2scale hub --> hub.go2scale.io

stages:
  - build

dotnet_build:
  image: alpine:3.12.1
  stage: build
  variables:
    DOTNET_OUTPUT: "/build"
    DOTNET_VERSION: "3.1"
    DOTNET_VERBOSITY: "minimal"
    DOTNET_CONFIG: "Debug"
    PROJECT_ROOT: "/"
  script:
    # Installing necessary stuff
    - apk add curl autoconf bash build-base clang clang-dev cmake curl-dev gcc gettext-dev git icu-dev krb5-dev libtool linux-headers llvm make zlib-dev
    # Downloading official dotnet install script
    - curl -O https://dotnet.microsoft.com/download/dotnet-core/scripts/v1/dotnet-install.sh
    - chmod +x dotnet-install.sh
    - bash dotnet-install.sh -Channel ${DOTNET_VERSION}
    # Working Directory
    - mkdir /app
    - cp ${CI_PROJECT_DIR}${PROJECT_ROOT}/*.csproj /app
    # For cache purposes, we restore dependencies
    - /root/.dotnet/dotnet restore
    - cp -r ${CI_PROJECT_DIR}${PROJECT_ROOT} /app
    - /root/.dotnet/dotnet publish -c ${DOTNET_CONFIG} -o ${CI_PROJECT_DIR}${DOTNET_OUTPUT} --no-restore -v ${DOTNET_VERBOSITY}
  artifacts:
    when: on_success
    expose_as: dotNET Build
    paths:
      - ${CI_PROJECT_DIR}${DOTNET_OUTPUT}
 No newline at end of file
+6 −0
Original line number Diff line number Diff line
name: dotnet_builder
description: A ready-to-use job to build .NET project
default_stage: build
icon: 🌐
maintainer: Protocole
license: MIT
 No newline at end of file
+1 −0
Original line number Diff line number Diff line
* Initial version