Hum …no thanks ! – Lordinaire

Category: Visual Studio (Page 1 of 2)

Build and deploy your Unity game with Visual Studio Online and App Center – Part 1

When you develop a game with Unity3D and you want to take advantage of the Microsoft ecosystem like Visual Studio Online, it can be hard to configure your CI/CD environment. This blog post will explain how to set up that from pushing code to deploy the game on device automatically.

  • Part 1 : Build with Unity CLI
  • Part 2 : Continuous Integration with Visual Studio Online
  • Part 3 : Continuous Delivery with Visual Studio Online
  • Part 4 : Deploy with App Center

I can’t cover all platforms so I will only focus on Android. It’s pretty much the same stuff  for other platforms. The name of the game will be : “Adam Must Live” (yes, it’s an in progress game ;))

Unity CLI

So, you have a game that you want to build for the Android platform. Great! What’s next ? Command line arguments.

The first thing to do is to create a script that can be used to build the game without any user interaction and the Unity CLI is the perfect target for doing that. Create a folder named Editor in your Assets folder and add a new script named MyEditorScript.cs :

using System.IO;
using System.Linq;
using UnityEditor;

public class MyEditorScript
    public static void PerformBuild()
        // Get all actives scenes
        var scenes = EditorBuildSettings.scenes.Where(s => s.enabled).Select(s => s.path).ToArray();

        var outputFile = "./Builds/Android/AdamMustLive.apk";
        if (File.Exists(outputFile))

        var buildPlayerOptions =
            new BuildPlayerOptions
                scenes = scenes,
                locationPathName = outputFile,
                target = BuildTarget.Android,
                options = BuildOptions.None

This static method can now be called be the CLI to build the game and generate the .apk file. We just need to run the command :

C:\Program Files\Unity\Hub\Editor\2018.1.1f1\Editor\Unity.exe -quit -batchmode -projectPath UNITY_PROJECT_PATH -executeMethod MyEditorScript.PerformBuild

We use the -batchmode to run Unity editor in a non-interactive mode (no user interaction will be required). The -quit option forces Unity to close himself when the task ends.

If you planned to install Unity on a machine hat don’t have a graphic card, you may need to add the parameter -nographics but some restrictions will be applied.

In the next post, we will see how to create a build definition with Visual Studio Online.


Working with Docker in Visual Studio 2017

Docker is a well-know tool in Microsoft ecosystem since few years. You can of course doing great things if you deal with Azure but it isn’t limited to “ops”. Developers can now easily play with Docker inside Visual Studio with some additional tools. Stuff like starting a container becomes so easy that everybody must use it! (I like Docker, a lot!)

Setup & Tools

First, you need to download and install Docker for Windows and select the .NET Core option in the installer of Visual Studio 2017.

Bonus: You can additionally download Kitematic (Visual Docker Container Management) if the CLI is not your friend.

Project sample

Let’s create a new ASP.NET Core 2.0 project of type WebAPI. The main benefit to target a .NET Core project is that it can run on Windows AND Linux platform.

Docker for Windows is able to run both of platforms type for a container but not a mixed use of it. So, you need that all your containers target the same platform, you can’t set a specific platform for a container. That’s the only limitation that I face off (and it can be a huge one…).

You can check the Enable Docker Support now or add it after when the solution will be created. If you doesn’t set the option, le solution explorer looks like that :

To activate the Docker support, right clic on the project and select Add > Enable Docker Support. Visual Studio will now automatically create a new project named docker-compose and a Dockerfile in your project. Well, thank you VS.


FROM microsoft/aspnetcore:2.0
ARG source
COPY ${source:-obj/Docker/publish} .
ENTRYPOINT ["dotnet", "WebApplication1.dll"]


version: '3'

    image: webapplication1
    context: ./WebApplication1
    dockerfile: Dockerfile

Start the project

Before starting the project, we need to check if the shared drives settings are set properly because Docker required full access to drives where the source code.

Update 04/11/17 : This is only needed if you use Linux containers with Docker for Windows. You can avoid that by using the option Switching to Windows containers.


To run your project with Docker, you need to set the docker-compose project as startup project. Hit F5 and open the console window : you will see all the steps like downloading the image, creating the container, …

Bonus: You can add breakpoints like you always do and it will work!

Bonus 2: If you launch Kitematic you will see your container with all his settings




Page 1 of 2

Powered by WordPress & Theme by Anders Norén

%d bloggers like this: