Migrating Existing C# Projects

If you have an existing project you wish to convert to Protobuild, you’ll need to perform a few steps to convert your current C# projects into project definition files.

If you haven’t used Protobuild before, we recommend reading Getting Started first so you can get acquainted with how Protobuild works first.

If your project uses #ifdef’s

If your project purely uses #ifdef to distinguish between platforms, then the migration process is easy.

1. Copy file declarations

For the project you want to convert, you’ll need to create a project definition that matches the current type of the project (refer to the relevant documentation pages for the type of project you need).

After this, copy all of the <Compile>, <Content>, <EmbeddedResource>, etc. tags from the C# project file into the definition file, removing the surrounding <ItemGroup> tags.

2. Migrate external references

For references to binary or external (unconverted) C# projects, you’ll need to create a new definition of an external project, the format of which is described in Defining External Projects. Use this to encapsulate external references, and then within your new Protobuild project definitions, reference the external project instead of binaries or C# projects directly.

If your project has multiple C# project files

If you have multiple C# projects, then the transition is going to be reasonably harder. You will need to determine the files present in each platform-specific project and from there, derive appropriate <Platforms> tags against the files, as demonstrated in Declaring files.

There is an experimental and unsupported shell script that can do this conversion enmass (reading all the project files and determining what declarations intersect). It is called find-platform-dependent-files.sh and can act as a good starting point for the conversion.

Explicitly setting Project GUIDs

By default, Protobuild generates unique GUIDs for all projects, based on their name and the platform being generated.

If you are migrating an existing library to Protobuild, and there are users currently using your library in source form, you’ll need to keep the GUIDs the same when you transition to Protobuild, so that existing users of your library won’t have the reference in their projects broken when you change.


If you do specify explicit project GUIDs, Protobuild can’t warn you of a GUID conflict, as we use conflicting project GUIDs to detect duplicate external project references in the solution.

You can explicitly set the project GUIDs as per the example below.

<?xml version="1.0" encoding="utf-8"?>
<Project Name="MyLibrary" Path="MyLibrary" Type="Library">
    <Platform Name="Android">CA9476CF-99BA-4D03-92F2-73D2C5E58883</Platform>
    <Platform Name="Angle">FCF3C8B9-0AAC-4C32-B184-FAE88F6244B5</Platform>
    <Platform Name="iOS">EB8508BB-9849-4CC2-BC0F-8EB5DACB3C47</Platform>
    <Platform Name="Linux">45253CE1-C864-4CD3-8249-4D1319748E8F</Platform>
    <Platform Name="MacOS">46C538E6-C32A-4A8D-A39C-566173D7118E</Platform>
    <Platform Name="Ouya">9BEA875D-66D2-4A5F-B137-83D262A3851D</Platform>
    <Platform Name="PSMobile">FA26E76F-FDFE-4A8C-B5A3-C3B5761E28F9</Platform>
    <Platform Name="Windows">8DE47032-A904-4C29-BD22-2D235E8D91BA</Platform>
    <Platform Name="Windows8">1518563C-ACCA-4A14-8C5D-DDBE93E2605F</Platform>
    <Platform Name="WindowsGL">7D75E618-19CA-4C51-9546-F10965FBC0B8</Platform>
    <Platform Name="WindowsPhone">CAA9A6E4-7690-4DE0-9531-DE0EAEEC9739</Platform>
    <Platform Name="WindowsPhone81">7522B7E9-25A5-4250-B164-42CC2C4ECCAD</Platform>
    <Reference Include="System" />
    <Reference Include="System.Core" />
    <Compile Include="MyClass.cs" />