Gitlab docker runner on Windows : msbuild fails

Viewed 343

For months I’m using several shared runners to run my GitLab CI job. All my runners are running on linux host or macOS and it works great! This job is compiling .Net Standard project using mono:latest image.

I use msbuild with nugget restore and here is my problem. I recently added my first shared runner on Windows, still using docker runner as usual such as described here (which is the way I always do). But with this new Windows shared runner and only this one my job fails when msbuild restore nugget packages from our local (subnetwork) nugget repository.

I tried installing another docker runner on another Windows host and same issue. I got this error:

error : Unable to load the service index for source http://skirnir/NuGet/index.json error : No such host is known

Skirnir is a local server where my nugget packages are hosted. I tried from my job to "curl http://login:pwd@skirnir/NuGet/index.json" and it works so when msbuild is executed from within the container using mono image it can access to Skirnir! But msbuild restore always fails to fetch packages. I tried to replace skirnir with its IP but same problem because index.json reference skirnir in "@id": "http://skirnir/NuGet/".

Here is my gitlab job:

cache:
  key: "$CI_JOB_NAME"
  paths:
    - packages

variables:
  MAIN_DIR: "Proj1"

before_script:
  - nuget help > /dev/null
  - cp $HOME/.config/NuGet/NuGet.Config .
  - nuget sources add -Name skirnir_ci -Source http://skirnir/NuGet/index.json -UserName $NUGET_USER -Password $NUGET_PASSWORD -configfile $(pwd)/NuGet.Config
  - export NUGET_PACKAGES=$(pwd)/packages

build pcl:
  image: mono
  stage: build
  tags:
    - docker
  retry: 2
  only:
    - tags
    - branches
    - web
  variables:
    PROJECT: "Proj1"
  script:
    - export MSBUILD_PROP="/p:Configuration=Release;RestoreConfigFile=$(pwd)/NuGet.Config"
    - msbuild /t:restore "$MSBUILD_PROP" $MAIN_DIR/$PROJECT/$PROJECT.csproj
    - msbuild "$MSBUILD_PROP" $MAIN_DIR/$PROJECT/$PROJECT.csproj

Any idea?

0 Answers
Related