# Package code

> Package your C# code into compression files before you deploy as a live Cloud Code module.


**The package code workflow. Use \`.NET\` to produce assemblies for your C# project, then compress the assemblies as \`.zip\` files or \`.ccm\` files before you deploy as a live Cloud Code module. :**
![The package code workflow. Use .NET to produce assemblies for your C# project, then compress the assemblies as .zip files or .ccm files before you deploy as a live Cloud Code module. ](/api/media?file=/cloud-code/media/images/cloud-code-manual-module-publishing-workflow.svg)

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.

* [Deploying using the UGS CLI](./write-modules/cli.md) requires you to package your code into a .ccm file.
* [Deploying using Cloud Code Admin API](./write-modules/rest-api.md) accepts either a .ccm file or a .zip file.

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

Refer to [Cloud Code Limits](../reference/limits) to check the storage limits.

> **Important:**
>
> This is a more advanced workflow. For most use cases, you can use the [Unity Editor](./write-modules/unity-editor.md) or the [UGS CLI](./write-modules/cli.md) 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](https://learn.microsoft.com/en-us/dotnet/core/deploying/ready-to-run) 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](./module-structure.md) that contains your Cloud Code module endpoints.

> **Note:**
>
> Using .NET 8.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](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-publish) for further details.

```sh
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.

```xml
<PropertyGroup>
<PublishReadyToRun>true</PublishReadyToRun>
</PropertyGroup>
```

Publish the module using the following command:

```sh
dotnet publish -c Release -r linux-x64
```

By default, this produces assembles in the `bin/Release/net8.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](https://learn.microsoft.com/en-us/dotnet/core/tutorials/publishing-with-visual-studio?pivots=dotnet-7-0) 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](https://www.jetbrains.com/help/rider/Run_Debug_Configuration_Publish_to_Folder.html) 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](https://support.microsoft.com/en-us/windows/common-file-name-extensions-in-windows-da4a4430-8e76-89c5-59f7-1cdbbc75cb01) to change the extension of the archive to .ccm.

The structure of the archive should look like this:

```text
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](./write-modules/cli.md#deploy-modules) or the [Cloud Code Admin API](./write-modules/rest-api.md#deploy-modules).
