Unity Gaming Services(Unity 游戏服务)CLI
Use the Unity Gaming Services command-line interface to create, deploy, and manage Cloud Code modules.
阅读时间4 分钟最后更新于 1 个月前
您可以使用 Unity Gaming Services(Unity 游戏服务)CLI 来处理 Cloud Code 模块。借助 CLI 可以从命令行创建、部署和管理 Cloud Code 模块。
先决条件
要深入了解 CLI,请按照 Unity Gaming Services(Unity 游戏服务)CLI 入门指南中的步骤操作。 为了按照该指南操作,必须首先完成以下操作:- 安装 UGS CLI。
-
按如下方式配置 Project ID 和环境:
ugs config set project-id <your-project-id>
ugs config set environment-name <your-environment-name> - 为服务帐户配置 Cloud Code 和环境管理所需的角色。请参阅接受身份验证。
使用 CLI
请参阅 Cloud Code 命令行文档,了解所有命令和选项的完整参考。创建模块
要使用示例模块在本地创建解决方案,可以运行new-file此命令使用示例模块创建新解决方案。 您可以按原样使用解决方案,也可以对其进行修改以满足您的需求。ugs cloud-code modules new-file <module-name> <module-directory>
部署模块
Deploy.ccmReleaseugs deploy <path-to-ccm-file> <path-to-sln-file>
ugs deploy <path-to-directory>
部署 C# 解决方案
您可以部署 C# 解决方案并使其在部署前自动编译和压缩。 为了支持编译,解决方案必须包含主项目的发布配置文件。 请参阅具体的集成开发环境文档以了解如何创建发布配置文件:- JetBrains Rider - 发布配置文件
- Visual Studio - 用于 ASP.NET Core 应用部署的 Visual Studio 发布配置文件 (.pubxml)
- Visual Studio - 使用 Visual Studio for Mac 发布到文件夹
<temp-folder>/<solution-name>.slnugs deploy <path-to-sln-file>
部署预编译的模块
要部署预编译的模块,请提供.ccmugs deploy <path-to-ccm-file>
环境同步
您可以将所有模块从一个环境移动并部署到另一个环境。 运行以下命令以生成当前环境中所有模块的存档:然后,可以通过运行以下命令导入模块并部署到另一个环境:ugs cloud-code modules export <out-dir> <file-name>
ugs cloud-code modules import <in-dir> <file-name> --environment-name <environment-name>
获取模块
要获取已部署的单个模块的相关信息,请运行以下命令:模块名称是包含在 .ccm 存档中的 .NET 类库的名称。还可以通过运行以下命令列出当前部署到 Cloud Code 的所有模块:ugs cloud-code modules get <module-name>
ugs cloud-code modules list
删除模块
要删除模块,请运行以下命令:ugs cloud-code modules delete <module-name>