我使用GitLab CE作为我们的源控制系统。它已经发布,但已更新到最新版本。
我有一个Runner配置为构建.net项目。
我有一个想要构建的dotNet核心项目。我遇到的问题是加载.net Build环境。我试图运行它来建立环境:
`- 'cmd /K "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsMSBuildCmd.bat"'
这是正确的,我得到这个输出:
$ cmd /K "C:\Program Files ^(x86^)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsMSBuildCmd.bat"
**********************************************************************
** Visual Studio 2017 MSBuild Command Prompt
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
C:\GitLab-Runner\builds\352e1762\0\online\WebApp>$ nuget restore src/Online-WebApp.sln
MSBuild auto-detection: using msbuild version '15.5.179.9764' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\bin'.
...rest removed...
问题是当它在Yml中获得作业步骤时,msbuild
命令被报告为无法识别。
这是完整的YAML。
请注意,手动设置PATH
可以找到msbuild
....
variables:
DATABASE_URL: "example=not-real" #just to show this is an option; https://docs.gitlab.com/ce/ci/variables/README.html
stages:
- build
before_script:
#- 'PATH=%PATH%;C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin'
#- 'cmd /K "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat"'
#- 'cmd /K "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\LaunchDevCmd.bat"'
- 'cmd /K "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsMSBuildCmd.bat"'
- 'nuget restore src/Online-WebApp.sln'
# What is important, is that each job is run independently from each other. "build" is a job.
build:
stage: build
script:
- 'msbuild src/Online-WebApp.sln /t:Clean,ReBuild /p:Configuration=Release;Platform="Any CPU"'
- 'dotnet pack src/Online-WebApp/Online-WebApp.csproj -c Release -v d --output nupkgs --no-build'
only:
- master