Documentation

Support

Unity Gaming Services CLI

Use the Unity Gaming Services command-line interface to create, deploy, and manage Cloud Code modules.
Read time 3 minutesLast updated 18 hours ago

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.

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.

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>

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>

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>

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>