This is how I would do it using Github:
jobs:
run-tests:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./MyApp
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build project
run: dotnet build --no-restore
- name: Run tests
run: dotnet test --no-build
This time on Gitlab my project solution file is in the root directory of the repository. I created a .gitlab-ci.yml
file and started with
image: mcr.microsoft.com/dotnet/sdk:5.0
stages:
- restore-dependencies
- build-solution
- run-tests
restore-dependencies:
stage: restore-dependencies
script:
- dotnet restore --packages packages
artifacts:
paths:
- packages
build-solution:
stage: build-solution
script:
- dotnet build --no-restore --source packages --output build
artifacts:
paths:
- build
dependencies:
- restore-dependencies
run-tests:
stage: run-tests
script:
- dotnet test --no-build --output build
dependencies:
- build-solution
The first job passes but the second one fails because it can't find the restored files from the first job. So my solution has a TestProject1
and the second job is not able to find a resource file in ...\TestProject1\obj\project.assets.json
How can I fix the pipeline configuration?