Running monogame-sdk.run on Linux without confirmation (Travis-CI)

I’m trying to build a “hello world” MonoGame project on Linux, which is straight-forward enough. Getting it to work on Travis-CI, not so much.

My problem is that running ./monogame-sdk.run asks the user for a confirmation (Y, n) to install. On Travis-CI, there’s no human present to pass in the input.

I don’t see any command-line arguments like --install-without-asking and I couldn’t figure out any way to send a Y to the process.

Is there any way to make this install without prompting the user?

I found this link on Stack Overflow, but it doesn’t seem to work (it’s for MonoGame 3.4, and it references generate.sh – plus it doesn’t seem to pass anything to monogame-sdk.run).

You can see a sample build failure here if you are so inclined.

I solved this with the following work-around:

  • Unpack monogame-sdk.run
  • Replace postinstall.sh with a version that doesn’t have the prompt
  • Profit

Here’s what the Travis config file looks like:

language: csharp
solution: MonoGameSample.sln
install:
  # MonoGame 3.6
  - sudo apt-get install gtk-sharp3
  - wget http://www.monogame.net/releases/v3.6/monogame-sdk.run  
  # Extract contents and overwrite postinstall.sh to not prompt for input
  # See: https://github.com/MonoGame/MonoGame/issues/5879
  - chmod +x monogame-sdk.run
  - sudo ./monogame-sdk.run --noexec --keep --target ./monogame
  - sudo chmod 777 ./monogame/postinstall.sh
  - cp Build/postinstall.sh ./monogame
  - cd monogame
  - sudo chmod +x postinstall.sh
  - sudo ./postinstall.sh
  - cd ..
  
  - nuget restore
  # NUnit
  - nuget install NUnit.Runners -Version 2.6.4 -OutputDirectory testrunner
script:
  - msbuild
  - mono ./testrunner/NUnit.Runners.2.6.4/tools/nunit-console.exe ./MonoGameSample.UnitTests/bin/Debug/MonoGameSample.UnitTests.dll

This also includes steps to install NUnit’s runner and run a unit-test DLL.

Build/postinstall.sh is a this version, with the selected lines removed.

I opened an issue (feature request?) about this here.