Prerequisites

This article covers building a MonoGame project with Azure DevOps.

  1. Existing MonoGame project
  2. Existing Azure DevOps project

MonoGame definition

I started the definition off by using the yaml template .NET Desktop, which allows us to build a Visual Studio solution.

MonoGame uses NSIS for wrapping up the Windows installer. NSIS provides a /S flag for running silent installs, however I was unable to get this to install silently. I opted to brute force install, and broke down the definition into three additional steps:

Download MonoGame

This step is pretty straightforward, define a new variable and download the MonoGame installer to a local file.

variables:
   monoGameVersion: 'v3.7.1' 
...
- 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)'

Extract MonoGame

Here I treat the installer as any old archive, and extract the files to a local folder.

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

Install MonoGame

The last step was created based on how I observed the MonoGame imports, properties and references in Visual Studio. It copies the necessary files that Visual Studio will use during compilation.

- 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)'

Wrapping it up

We created a new Azure Pipelines definition, which allows us to build MonoGame projects including the Content pipeline.

For some additional details check out this article’s