Package code

To deploy a module, you must package the code into an archive. The archive can be a .ccm file or a .zip file, depending on the authoring method you use to deploy your module. The .ccm file is simply a ZIP file with its extension changed to .ccm.

The archive can only contain the packaged assemblies to run on x64 Linux.

Refer to Cloud Code Limits to check the storage limits.

Important: This is a more advanced workflow. For most use cases, you can use the Unity Editor or the UGS CLI to deploy your modules with automatic packaging, and skip this step.

Ready to Run (R2R) compilation

You can enable Ready to Run compilation when producing assembles for your module project. This can slightly improve the cold start time for your module, but it won't improve the response time after the first call. The option also increases the size of the assemblies. Check Microsoft documentation on ReadyToRun Compilation for further details.

Producing assemblies

To produce assemblies in this format, use the .NET command-line interface (CLI) or an IDE such as JetBrains Rider or Microsoft Visual Studio as described in the sections below. You must produce assemblies only for the main module project that contains your Cloud Code module endpoints.

Note: Using .NET 6.0 is recommended.

Using the .NET command-line interface

To produce assemblies with the .NET CLI, use the dotnet publish command. Refer to Microsoft documentation on dotnet publish for further details.

dotnet publish -c Release -r linux-x64 -p:PublishReadyToRun=true

You can specify the target platform and R2R compilation in the project by adding the <PublishReadyToRun> setting.

<PropertyGroup>
<PublishReadyToRun>true</PublishReadyToRun>
</PropertyGroup>

Publish the module using the following command:

dotnet publish -c Release -r linux-x64

By default, this produces assembles in the bin/Release/net6.0/linux-x64/publish folder.

Using Microsoft Visual Studio

You can produce assemblies with Microsoft Visual Studio. To do so, follow these steps:

  1. Right-click the C# project for the module and select Publish from the menu.
  2. Do the following on the Publish page:
    1. Select Folder as target and then Next.
    2. Select Folder as specific target and then Next.
    3. Select Finish.
    4. On the Publish profile creation progress page, select Close.
    5. In the Publish window's Publish tab, select Show all settings.
    6. Make sure that the target runtime is linux-x64.
    7. (Optional) Make sure that PublishReadyToRun is activated.
    8. Select Publish

Check the tutorial Publish a .NET console application using Visual Studio from the Microsoft documentation for further detail.

Using JetBrains Rider

You can produce assemblies with JetBrains Rider. To do so, follow these steps:

  1. Open Run > Edit Configurations..., or select Edit Configurations from the navigation bar.
  2. Select + > Add New Configuration.
  3. Choose the Publish to folder configuration type.
  4. Set Target runtime to linux-x64.
  5. (Optional) Activate Enable ReadyToRun compilation.
  6. Select Apply to save the configuration.
  7. When you are ready to publish your module, select the run configuration you created on the toolbar, then Run.

Check JetBrains Rider documentation Publish .NET applications to folder for further details.

Packaging the assemblies

After producing these assemblies, compress them in an archive. If you plan to deploy using the UGS CLI, you can set the archive extension to .ccm.

Note: If you are using file explorer in Windows, you must enable common file name extensions to change the extension of the archive to .ccm.

The structure of the archive should look like this:

MyModule.ccm
├─ MyModule.dll
├─ MyModule.deps.json
├─ Dependency1.dll
├─ Dependency2.dll
└─ ...

By default, this will include the dependencies of Cloud Code NuGet packages.

Note: The produced assemblies also contain .pdb files. These files are necessary to produce a stack trace with line numbers. However, they are not required to run your module.

You can then deploy the archive using the UGS CLI or the Cloud Code Admin API.