gitgitlabgitversion

Error "-outputfile" when building a project on gitlab


In my project, I use the GitVersion.MsBuild library to keep track of the application version on the wpf.

When building in gitlab there is an

error MSB3073: 
exit command ..\net48/gitversion.exe C:\gitlab-runner\builds\...\imgupd\Wpf \
             -output file -outputfile C:\gitlab-runner\builds\DN7xGEXb\0\...\Wpf/gitversion.json" \
with code 1. 
[C:\gitlab-runner\builds\DN7xGEXb\0\..\Wpf.csproj]

Has anyone else encountered this problem?
The network says that the problem has been solved with the release of a new version of the GitVersion.MsBuild library, but I still get this error.

My gitlab-ci file looks like this

variables:
  EXE_RELEASE_FOLDER: 'Wpf\bin\Release\netcoreapp3.1'
  NUGET_PATH: 'C:\NuGet\nuget.exe'
  MSBUILD_PATH: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\msbuild.exe'
  ARTIFACTS_NAME: "imgupd"
stages:
  - build
 #- test
  - deploy

build_job:
  stage: build
  before_script:
  - CHCP 65001
  rules:
    - if: $CI_COMMIT_BRANCH
      when: on_success
      allow_failure: false
    - if: $CI_COMMIT_TAG
      when: on_success
      allow_failure: false
  script:
    - '& "$env:NUGET_PATH" restore' # restore Nuget dependencies
    - '& "$env:MSBUILD_PATH" /p:Configuration=Release /clp:ErrorsOnly' # build the project
    - '$deployFolder = $($env:ARTIFACTS_NAME) + "\"'
    - 'xcopy /y /e ".\$env:EXE_RELEASE_FOLDER\*" "$deployFolder"'
  artifacts:
    name: "$env:ARTIFACTS_NAME"
    expire_in: 1 week # save gitlab server space, we copy the files we need to deploy folder later on
    paths:
      - '$env:ARTIFACTS_NAME\' # saving exe to copy to deploy folder
     #- '$env:MSI_RELEASE_FOLDER\Configurator Setup.msi' # saving msi to copy to deploy folder

deploy_job:
  stage: deploy
  before_script:
  - CHCP 65001
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
      when: never
    - if: $CI_COMMIT_BRANCH
      when: on_success
      allow_failure: false
    - if: $CI_COMMIT_TAG
      when: on_success
      allow_failure: false
script:
  - '$commitSubject = git log -1 --pretty=%s'

dependencies:
  - build_job

Solution

  • This is still reported and followed with GitTools/GitVersion issue 2993.

    It does include the caveat (for GitHub Actions):

    For GitVersion to execute successfully, it needs the full repository history.

    By default, actions/checkout does a shallow clone. Add the following to the workflow and it should at least be able to execute:

       - uses: actions/checkout@v2
         with:
           fetch-depth: 0
    

    Double-check in your gitlab-ci if you have a shallow clone (IE: GIT_DEPTH set).

    If not, check if this is related to issue 2534: Build error due to malformed file path obj\/gitversion.json, since your error message also include such a \/ path separator combination.