如何安装 MSbuild 以在 Gitlab 管道中构建我的 dotnet 框架项目?

How to install MSbuild to build my dotnet framework project in Gitlab pipeline?

我想用Gitlab来fullfill CICD

.shared_windows_runners:
  tags:
  - shared-windows
  - windows
  - windows-1809
variables:
  MSBUILD_PATH: './tools/msbuild.exe'

stages:
  - build

build:
  extends:
  - .shared_windows_runners
  stage: build
  image: mcr.microsoft.com/dotnet/framework/sdk
  script: 
    - echo "test"
    - '& "$env:MSBUILD_PATH" WebCICD.sln'

我的 .Net 版本:.NET Framework 4.6.2

下面可以,但我不知道如何安装 MSBuild。

我从下载页面下载了 MSBuild。

这是一个名为 BuildTools_Full.exe

的文件

似乎是安装程序文件。

我应该把它推到 gitlab 并像 bin 文件一样对待它吗?

然后尝试输入“Msbuild.exe myProject”?

我的回购:https://gitlab.com/catsheue/dotnetframeworkcicd

如果您已经安装了 MSBuild 或刚刚下载了它,请创建一个新变量并将路径设置为 msbuild.exe 文件,然后在您的脚本中使用它。我在代码片段中添加的路径是默认安装路径。它也可能对你有用。否则你需要弄清楚 msbuild.exe 在哪里。

.shared_windows_runners:
  tags:
  - shared-windows
  - windows
  - windows-1809
variables:
  MSBUILD_PATH: 'C:\Program Files (x86)\Microsoft Visual Studio19\BuildTools\MSBuild\Current\Bin\msbuild.exe' or the path to msbuild.exe

stages:
  - build

build:
  extends:
  - .shared_windows_runners
  stage: build
  image: mcr.microsoft.com/dotnet/framework/sdk
  script: 
    -'& "$env:MSBUILD_PATH" YOUR_PROJECT.sln /p:Configuration="YOUR_CONF"