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

Imports Orcus.Administration.Plugins

Public Class Plugin
    Implements IBuildPlugin

    Public Function DoWork(ByRef path As String, buildLogger As IBuildLogger) As Boolean Implements IBuildPlugin.DoWork
        Throw New NotImplementedException
    End Function

    Public Sub OpenSettings(ownerWindow As Window) Implements IBuildPlugin.OpenSettings
        Throw New NotImplementedException
    End Sub

    Public ReadOnly Property SettingsAvailable As Boolean Implements IBuildPlugin.SettingsAvailable
    Public ReadOnly Property BuildType As BuildType Implements IBuildPlugin.BuildType
End Class

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 sub. 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 sub OpenSettings will get called. Then you can open a custom window to allow the user to make settings.

Imports Orcus.Administration.Plugins

Public Class Plugin
    Implements IBuildPlugin

    Public Sub New()
        BuildType = BuildType.Final
        SettingsAvailable = False
    End Sub

    Public Function DoWork(ByRef path As String, buildLogger As IBuildLogger) As Boolean Implements IBuildPlugin.DoWork
        'Do your work here
        Return True
    End Function

    Public Sub OpenSettings(ownerWindow As Window) Implements IBuildPlugin.OpenSettings
        'This won't get called because SettingsAvailable is False
        Throw New NotImplementedException
    End Sub

    Public ReadOnly Property SettingsAvailable As Boolean Implements IBuildPlugin.SettingsAvailable
    Public ReadOnly Property BuildType As BuildType Implements IBuildPlugin.BuildType
End Class

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


Sample Projects