Build Plugin

Description

A build plugin modifies the build. It is selectedable by the user in the build section and is called when the user builds a new client.


Needed libraries


Let's start

Because this is a plugin which will be loaded by the administration, we have to address the .Net Framework 4.5. If you want to provide a settings window, you should create a WPF User Control Library, but a Class Library also works.



The next thing to do is to add the interface library Orcus.Administration.Plugins.dll to the references. You can do that with a right click on References in the Solution Explorer and then a click on Add Reference.... You can find the library in the /libraries folder of your Orcus package. Make sure that you have the newest version. The next thing to do is to create a new class called Plugin (the name doesn't matter, but it makes clear that it's the entry point). REALLY IMPORTANT: the class must be public.

The next step is to implement the interface from the library called IBuildPlugin

using System;
using System.Windows;
using Orcus.Administration.Plugins;

namespace MyBuildPlugin
{
    public class Plugin : IBuildPlugin
    {
        public bool DoWork(ref string path, IBuildLogger buildLogger)
        {
            throw new NotImplementedException();
        }

        public void OpenSettings(Window ownerWindow)
        {
            throw new NotImplementedException();
        }

        public bool SettingsAvailable { get; }
        public BuildType BuildType { get; }
    }
}

As you can see, there are two properties, one method and one function. The core function is DoWork. It gets called when the plugin should do it's work. The first parameter path is the current path to the binary file. You can change it by just setting it. The second parameter contains the build logger which pushes all messages to build window. The return value defines if your work was successful. If you return false, the build progress will get canceled.

Really important is the property BuildType. It defines when the plugin is called. If you have to do work which needs the clear IL code, it will be called before an obfuscator.

The last thing is the SettingsAvailable property and the dependent OpenSettings void. If you want the user to change settings, you can set SettingsAvailable to true and the button will be activated:



The first two plugins have SettingsAvailable set to true, the last one not. If the user clicks on the Open button, the void OpenSettings will get called. Then you can open a custom window to allow the user to make settings.

using System;
using System.Windows;
using Orcus.Administration.Plugins;

namespace MyBuildPlugin
{
    public class Plugin : IBuildPlugin
    {
        public bool DoWork(ref string path, IBuildLogger buildLogger)
        {
            //Do your work here
            return true;
        }

        public void OpenSettings(Window ownerWindow)
        {
            //This won't get called because SettingsAvailable is false
            throw new NotImplementedException();
        }

        public bool SettingsAvailable { get; } = false;
        public BuildType BuildType { get; } = BuildType.Final;
    }
}

If you want to provide settings, create a new Window and open that in the OpenSettings void. Don't forget to set it's owner to the ownerWindow.


Sample Projects