GitLab 中的 CI 管道

问题描述 投票:0回答:1

我是 GITLAB 的新手。我已经创建了一个存储库并将我的代码推送到存储库。 我正在尝试创建管道来构建该项目。 帮助我创建正确的 yml 文件来构建管道。

default:
  tags:
    - windows

stages:
  - build


build_job:
  stage: build
  script:
  - 'echo building...'
  - $msbuild = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe"
  - '&$msbuild WebApplication1.sln'
Error
& : The term 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe' is not 
recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if 
a path was included, verify that the path is correct and try again.
At line:262 char:2
+ &$msbuild WebApplication1.sln
+  ~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Program File...Bin\MSBuild.exe:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
 
Cleaning up project directory and file based variables
00:02
ERROR: Job failed: exit status 1
gitlab continuous-integration gitlab-ci
1个回答
0
投票

确保基于您的路径的可执行文件存在,然后尝试以下代码:

stages:
  - build

variables:
  MSBUILD_PATH: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe'

build:
  stage: build
  script:
    - '& "$env:MSBUILD_PATH" WebApplication1.sln'
© www.soinside.com 2019 - 2024. All rights reserved.