Adam's blog formerly game development, now just casual madness

Package Management in Duality

If you’re a C# developer, there’s a good chance that you already know what NuGet is, or at least have overheard someone talking about it. The main idea is to stop delivering precompiled dependencies along with source code, and instead provide a central repository where all these binary packages are stored. Whenever someone needs one of them, it can be downloaded automatically, and whenever a new version is available, upgrading is only a mouse click away. Package Management is just incredibly convenient – and now, Duality makes use of it. Let’s take a quick look at how it works.

First, you’ll need to download a special version of Duality, because Package Management is still in its early beta stage. As usual, unpack it and open the newly created folder. You will notice that the contents of the package have changed dramatically, compared to previous Duality versions:

Most of the usual files are gone, but that’s fine. When running DualityEditor.exe, it will download all the required files automatically as configured in PackageConfig.xml:

<?xml version="1.0" encoding="utf-8"?>
<PackageConfig>
  <RepositoryUrl>https://packages.nuget.org/api/v2</RepositoryUrl>
  <Packages>
    <Package id="AdamsLair.Duality" />
    <Package id="AdamsLair.Duality.Launcher" />
    <Package id="AdamsLair.Duality.Editor" />
    <Package id="AdamsLair.Duality.Plugins.Compatibility" />
    <Package id="AdamsLair.Duality.Editor.Plugins.Base" />
    <Package id="AdamsLair.Duality.Editor.Plugins.CamView" />
    <Package id="AdamsLair.Duality.Editor.Plugins.HelpAdvisor" />
    <Package id="AdamsLair.Duality.Editor.Plugins.LogView" />
    <Package id="AdamsLair.Duality.Editor.Plugins.ObjectInspector" />
    <Package id="AdamsLair.Duality.Editor.Plugins.ProjectView" />
    <Package id="AdamsLair.Duality.Editor.Plugins.SceneView" />
    <Package id="AdamsLair.Duality.Editor.Plugins.PackageManagerFrontend" />
  </Packages>
</PackageConfig>

Duality has been split up into quite a lot of distinct packages, reflecting the already existing modular architecture. Each package consists of the appropriate binary files and a description, all stored in a central NuGet repository. As no specific versions are stated in the initial config file, NuGet will simply go get the newest ones that are available. This is what you will see when proceeding to run the editor:

Depending on your internet connection, this may take some seconds to a minute. After finishing the download, the editor will restart to apply the update and then behave as usual. So what’s the big deal?

Prior to Package Management, when you wanted to extend Duality with a third-party plugin, you had to crawl the web to locate the download link, unzip it, follow installation instructions and then hope for the best. In some cases, those binary packages didn’t even exist and you had to build the plugin yourself and then figure out how to install it on top of that. All of this will be gone when Package Management is out of beta. Open the “File / Manage Packages…” dialog to see how it works.

You will find a list of all the Duality packages that are currently installed, along with their version and a color annotation depicting whether or not this version is the latest available one. In order to update an outdated package, simply select it and hit the Update button. Un/Installing packages works similar, but you may need to select “Filter by: Online Repository” first, in order to view all the available packages. You can perform as many operations as you like, but in order to apply these changes, a final editor restart will be required.

Depending on the changes introduced by updated packages, you may need to update your custom plugin code as well after the restart. It should be fine in most cases, but the safe path a simple recompile-and-fix before touching any game content. And that’s about it: You can now add, update and remove plugin functionality to and from Duality with this neat new dialog, and it will take care of the rest.

Since this is a pretty big step, I will need lots of beta testers before I can flip the “live” switch on this, and “lots of beta testers” essentially means “you”: Go get it. And let me know what you think.

19 of 74