Azure 管道 MSBuild

Azure Pipeline MSBuild

我是整个 Azure 管道的新手。我在 .net Framework 上有一个项目 运行,我想使用 MSBuild 创建 YAML 以执行以下操作:

  1. 清洁液
  2. 恢复 Nuget 包
  3. 构建解决方案
  4. 运行 单元测试(在不同的文件夹中)
  5. 打包发布

有人可以帮助我吗?

要在 Azure DevOps 管道中使用 YAML,您可以从头开始创建一个新的 YAML 管道:

要在管道中添加更多任务,您可以单击 Show assistant 和 select 您需要的任务:

.yml 文件可能如下所示:

trigger:
- master

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'   

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'
    clean: true

- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'drop'
    publishLocation: 'Container'

由于您是 Azure DevOps 的新手并且想从 YAML 开始,请参阅我们的 Azure Pipelines documentation for great getting started guides and examples. More information, you could refer to YAML schema documentation. You can also find additional documentation and samples in azure-pipelines-yaml GitHub 存储库。