Skip to main content
Version: v16.x - Umbraco 16

Adding Root Folders Programatically

By default, uSync will build the collection of folders it uses to import/export items from the appsettings.

The default folders are:

  • uSync/roots
  • uSync/version (e.g v16)

You can add to these folders in the [appsettings.json] file, but you can also include folders programatically by having a public class implement the ISyncFolder interface in your code.

public interface ISyncFolder
{
/// <summary>
/// path to the folder we want to use.
/// </summary>
string Path { get; }

/// <summary>
/// weight in the list.
/// </summary>
int Weight { get; }
}

For example:

public class TestSyncFolder: ISyncFolder
{
public string Path => "uSync/Test";
public int Weight => 100;
}

uSync will load these ISyncFolder classes at start up and order them based on the weight.

The configured folders are loaded with a default weighting and gap of 1000.

For example, with the default config, and the sample TestSyncFolder class above, the folders would be wieghted as below:

FolderSourceWeight
uSync/rootconfig0
uSync/testcode100
uSync/v16config1000

uSync will import from the collection of folders.

Depending on the configuration, the files will be combined or overwritten and a final virtual 'combined' folder will be used for imports.