Unity Gaming Services CLI

You can use the Unity Gaming Services CLI to interact with Cloud Code modules. The CLI allows you to create, deploy, and manage Cloud Code modules from the command line.

Prerequisites

For a deep dive into the CLI, follow the steps in the Unity Gaming Services CLI Get Started guide.

To follow this guide, you must first complete the following actions:

  1. Install the UGS CLI.

  2. Configure your Project ID and Environment as such:
    ugs config set project-id <your-project-id>
    ugs config set environment-name <your-environment-name>

  3. Configure a Service Account with the required roles for Cloud Code and environments management. Refer to Get Authenticated.

Using the CLI

Refer to the Cloud Code Command Line documentation for a full reference of all commands and options.

Note: The ugs cloud-code modules command is also available as ugs cc m.

Note: The CLI does not currently support custom tags for modules, and they will be ignored. If you would like to attach custom key-value pairs to your modules, use the Cloud Code API.

Create modules

To locally create a solution with a sample module, you can run the new-file command:

ugs cloud-code modules new-file <module-name> <module-directory>

The command creates a new solution with a sample module.

You can either use the solution as it is or modify it to suit your needs.

Note: Storage limits apply. Check Cloud Code Limits.

Deploy modules

The Deploy command allows you to deploy Cloud Code modules to the remote environment. The command supports both pre-compiled modules in .ccm format and C# solutions, which automatically compile and zip before deployment.

By default, the deployment is based on the Release build configuration of your solution. This configuration should avoid including extra content such as test projects to reduce the size. To learn more on build configurations, visit Rider or Visual Studio's documentation.

To deploy multiple modules at once, either provide multiple file paths or a directory containing multiple files:

ugs deploy <path-to-ccm-file> <path-to-sln-file>
ugs deploy <path-to-directory>

Deploy C# solutions

You can deploy C# solution and have it automatically compile and zip before deployment.

To support compilation, the solution must contain a publish profile for the main project.

Refer to specific IDE documentation to learn how to create a publish profile:

When deploying solutions, they automatically compile and zip before deployment. The result saves your local temporary folder (for example, <temp-folder>/<solution-name>).

To deploy C# solutions, provide a path to a .sln file as an argument to the command:

ugs deploy <path-to-sln-file>

Important: Currently, the solution deployment supports only one main project per solution. The main project is the project that contains a publish profile. You can't deploy solutions that contain multiple modules. Additionally, make sure all projects for this solution are under the solution file in the folder hierarchy. To understand how to structure your solution, refer to Module structure.

Deploy pre-compiled modules

To deploy pre-compiled modules, provide a path to a .ccm file as an argument to the command:

ugs deploy <path-to-ccm-file>

Note: For most use cases, you can use the deploying solutions workflow. As a more advanced workflow, you can package and deploy pre-compiled modules. To learn how to compress your module into a .ccm file, refer to Package code.

Environment synchronization

You can move all your modules from one environment and deploy them to another environment.

Run the following command to produce an archive of all the modules in your current environment:

ugs cloud-code modules export <out-dir> <file-name>

You can then import the modules and deploy them to another environment by running the following command:

ugs cloud-code modules import <in-dir> <file-name> --environment-name <environment-name>

Note: Import does not overwrite your environment by default. If you would like to delete existing modules before importing, use the --reconcile flag.

Retrieve modules

To get information about a single module that you deployed, run the following command:

ugs cloud-code modules get <module-name>

The module name is the name of the .NET class library that is contained within the .ccm archive. You can also list all modules currently deployed to Cloud Code by running the following command:

ugs cloud-code modules list

Delete module

To delete a module, run the following command:

ugs cloud-code modules delete <module-name>