1
votes

I have complex-ish C# solution to build through Azure Pipelines.

This is a MonoGame v3.7.1 project with several projects that I'm hosting in a public GitHub repo. The solution structure looks like this:

- AzureTest
    - AzureTest.Core
    - AzureTest.DirectX
    - AzureTest.OpenGL

The Core project is a shared project and cannot be run, while DirectX and OpenGL both reference .Core and can be run. All game code will live in the Core project.

My current azure-pipelines.yml config file looks like this:

# .NET Desktop
# Build and run tests for .NET Desktop or Windows classic desktop solutions.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/apps/windows/dot-net

trigger:
  branches:
    include:
    - '*'

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'x86'
  buildConfiguration: 'Release'
  monoGameVersion: 'v3.7.1'

steps:
- task: GitVersion@5
  inputs:
    runtime: 'full'
    updateAssemblyInfo: true
    configFilePath: 'gitversion.yml'

- script: |
    powershell -Command "(New-Object System.Net.WebClient).DownloadFile('https://github.com/MonoGame/MonoGame/releases/download/$(monoGameVersion)/MonoGameSetup.exe', '.\MonoGameSetup.exe')"
  displayName: 'Download MonoGame $(monoGameVersion)'

- task: ExtractFiles@1
  inputs:
    archiveFilePatterns: 'MonoGameSetup.exe'
    destinationFolder: './tmp/'
  displayName: 'Extract MonoGame $(monoGameVersion)'

- script: |
    mkdir "%PROGRAMFILES(X86)%\MSBuild"
    xcopy .\tmp\$PROGRAMFILES\MSBuild "%PROGRAMFILES(X86)%\MSBuild" /E /Y
    mkdir "%PROGRAMFILES(X86)%\MonoGame\v3.0\Assemblies\"
    xcopy .\tmp\Assemblies "%PROGRAMFILES(X86)%\MonoGame\v3.0\Assemblies" /E /Y
  displayName: 'Install MonoGame $(monoGameVersion)'

- task: NuGetToolInstaller@1

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

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

This downloads the specified version of MonoGame, extracts and installs it (I found the config from this article). Understandibly, this will just build whatever project is set as the startup project in the solution. I'm also using GitVersion for auto-versioning, the config file looks like this:

mode: Mainline
branches: {}
ignore:
  sha: []

I would like to run a pipeline job/task/stage that builds the DirectX project under Windows, and the OpenGL project under Windows, MacOS and Linux, and possibly create artifacts for each build, though I haven't looked into artifacts yet. I'm fairly new to using Azure Pipelines so I'm unsure if I should create separate azure-pipeline.yml files for each platform/project, or if I can define the platform config in a single pipeline config.

1
I haven't had a chance to work on this recently. I need to create a job town download and install MonoGame for MacOS and Linux.Matt Clegg

1 Answers

2
votes

so I'm unsure if I should create separate azure-pipeline.yml files for each platform/project, or if I can define the platform config in a single pipeline config.

The answer is yes. You could use the multiple jobs in parallel with multiple agents, like:

jobs:
- job: Windows
  pool:
    vmImage: 'vs2017-win2016'
  steps:
  - script: echo hello from Windows
- job: macOS
  pool:
    vmImage: 'macOS-10.14'
  steps:
  - script: echo hello from macOS
- job: Linux
  pool:
    vmImage: 'ubuntu-16.04'
  steps:
  - script: echo hello from Linux

So, we could builds the DirectX project with Windows agent in the job1 and build OpenGL project under Windows, MacOS and Linux in the job2, job3, job4 with corresponding agent.

Note: If you have a priority order between several jobs, please pay attention to using dependsOn:

You could check the details info from the document Specify jobs in your pipeline.

Hope this helps.