错误”-outputfile” 在 GitLab 上构建项目时发生。

huangapple go评论74阅读模式
英文:

Error "-outputfile" when building a project on gitlab

问题

在我的项目中,我使用GitVersion.MsBuild库来跟踪wpf应用程序的版本。

在GitLab构建时,出现了以下错误:

错误 MSB3073:退出命令..\net48/gitversion.exe C:\gitlab-runner\builds\...\imgupd\Wpf \
-output file -outputfile C:\gitlab-runner\builds\DN7xGEXb
错误 MSB3073:退出命令..\net48/gitversion.exe C:\gitlab-runner\builds\...\imgupd\Wpf \
-output file -outputfile C:\gitlab-runner\builds\DN7xGEXb\0\...\Wpf/gitversion.json" \
带有代码1。
[C:\gitlab-runner\builds\DN7xGEXb\0\..\Wpf.csproj]
\.
..\Wpf/gitversion.json" \
带有代码1。 [C:\gitlab-runner\builds\DN7xGEXb
错误 MSB3073:退出命令..\net48/gitversion.exe C:\gitlab-runner\builds\...\imgupd\Wpf \
-output file -outputfile C:\gitlab-runner\builds\DN7xGEXb\0\...\Wpf/gitversion.json" \
带有代码1。
[C:\gitlab-runner\builds\DN7xGEXb\0\..\Wpf.csproj]
\.
.\Wpf.csproj]

有其他人遇到这个问题吗?
网络上说,这个问题已经在发布新版本的GitVersion.MsBuild库后解决了,但我仍然遇到这个错误。

我的gitlab-ci文件如下:

variables:
  EXE_RELEASE_FOLDER: 'Wpf\bin\Release\netcoreapp3.1'
  NUGET_PATH: 'C:\NuGet\nuget.exe'
  MSBUILD_PATH: 'C:\Program Files (x86)\Microsoft Visual Studio19\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' # 恢复Nuget依赖项
    - '& "$env:MSBUILD_PATH" /p:Configuration=Release /clp:ErrorsOnly' # 构建项目
    - '$deployFolder = ($env:ARTIFACTS_NAME) + "\"'
    - 'xcopy /y /e ".$env:EXE_RELEASE_FOLDER\*" "$deployFolder"'
  artifacts:
    name: "$env:ARTIFACTS_NAME"
    expire_in: 1 week # 保存GitLab服务器空间,稍后将文件复制到部署文件夹
    paths:
      - '$env:ARTIFACTS_NAME\' # 保存exe以复制到部署文件夹
     #- '$env:MSI_RELEASE_FOLDER\Configurator Setup.msi' # 保存msi以复制到部署文件夹

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

请注意,我只翻译了您的代码部分,其他部分保持不变。

英文:

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
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]
\.
..\Wpf/gitversion.json" \
with code 1. [C:\gitlab-runner\builds\DN7xGEXb
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]
\.
.\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 Studio19\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

答案1

得分: 0

这仍然是一个已报告并正在跟踪的问题,详见GitTools/GitVersion问题2993

对于GitHub Actions,需要注意以下事项:

> 为了使GitVersion成功执行,它需要完整的存储库历史记录。
>
> 默认情况下,actions/checkout执行浅克隆。请将以下内容添加到工作流程中,至少应该能够执行:
>
> yaml > - uses: actions/checkout@v2 > with: > fetch-depth: 0 >

请在您的gitlab-ci中双重检查是否存在浅克隆(即:设置了GIT_DEPTH

如果没有,请检查是否与问题2534相关:由于您的错误消息中还包含了\/路径分隔符组合,导致构建错误,如obj\/gitversion.json

英文:

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:
>
> yaml
> - 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.

huangapple
  • 本文由 发表于 2023年1月9日 14:28:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/75053815.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定