C
C#2mo ago
NykyTV

Problem with the dotnet installation in gitlab-ci (Docker, Debian11)

im using the official dotnet-install.sh script in the install stage https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script this is my current .gitlab-ci.yml:
stages:
- install
- build

install-job:
stage: install
script:
- apt-get update
- apt-get install sudo
- apt-get install curl -y
- apt-get install wget -y
- chmod +x dotnet-install.sh
- sudo ./dotnet-install.sh --runtime dotnet --version 8.0.0
tags:
- .net
- c#

build-job:
stage: build
script:
- dotnet --version
- echo "Compiling the code..."
- dotnet build
- echo "Compile complete."
tags:
- .net
- c#
stages:
- install
- build

install-job:
stage: install
script:
- apt-get update
- apt-get install sudo
- apt-get install curl -y
- apt-get install wget -y
- chmod +x dotnet-install.sh
- sudo ./dotnet-install.sh --runtime dotnet --version 8.0.0
tags:
- .net
- c#

build-job:
stage: build
script:
- dotnet --version
- echo "Compiling the code..."
- dotnet build
- echo "Compile complete."
tags:
- .net
- c#
build-job error:
$ dotnet --version
/bin/bash: line 147: dotnet: command not found
$ dotnet --version
/bin/bash: line 147: dotnet: command not found
I have been looking for solutions for over 2 hours now, but nothing has worked. Can anyone help me?
8 Replies
Furtun
Furtun2mo ago
You need to either use artifacts or caches to cache your installation. Your two jobs can be run on different agents so the installation doesn't automatically carry over. As a quick fix, just move the dotnet installation inside the build job and then it'll work
NykyTV
NykyTVOP2mo ago
i already tried to put everything in one job but it doesn't work
Furtun
Furtun2mo ago
It has to work. I've never used gitlab but I've set up GitHub actions, which should basically be the same thing. If the installation succeeds, I've never seen it not be able to run. But regardless, can you check if there's already agents with existing dotnet installations, so you don't have to do your own installation? https://stackoverflow.com/a/52321137
Stack Overflow
Build .NET solution using GitLab CI Pipeline
I have a solution with several .NET projects in it. I use GitLab, not self-hosted, for version control and would like to start using their CI tools as well. I have added the following .gitlab-ci.ym...
Furtun
Furtun2mo ago
Also maybe the dotnet installer is not made for agents? I have some very vague recollection about some specific dotnet installer for build agents, you can try to search for that as well
NykyTV
NykyTVOP2mo ago
i installed now the mono:latest image and it seems to run and install without the installer. But now there is this error while building with 'dotnet build': error NETSDK1178: The project depends on the following workload packs that do not exist in any of the workloads available in this installation: Microsoft.iOS.Sdk.net8.0_18.0 and error NETSDK1178: You may need to build the project on another operating system or architecture, or update the .NET SDK.
Furtun
Furtun2mo ago
You need some specific workload, but idk what. Try to figure out what workload you need and try to install it in your job https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-workload-install
dotnet workload install command - .NET CLI
The 'dotnet workload install' command installs optional workloads.
NykyTV
NykyTVOP2mo ago
yeah this is my workload install command
sudo dotnet workload install maui-android maui-ios
sudo dotnet workload install maui-android maui-ios
i added maui-ios because of the 1st error: Microsoft.iOS.Sdk.net8.0_18.0 the installation works without the maui-ios but i guess ill need it. this is the error message from the job: Workload installation failed: Workload ID maui-ios isn't supported on this platform. do you have any other ideas which platform/image could work?
Furtun
Furtun2mo ago
Tbh no because I don't use gitlab, but maybe they have a Maui image. Could you try to find their image repository? It should be documented somewhere
Want results from more Discord servers?
Add your server