T2FGame.Samples.ProtoExport
1.0.4
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package T2FGame.Samples.ProtoExport --version 1.0.4
NuGet\Install-Package T2FGame.Samples.ProtoExport -Version 1.0.4
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="T2FGame.Samples.ProtoExport" Version="1.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="T2FGame.Samples.ProtoExport" Version="1.0.4" />
<PackageReference Include="T2FGame.Samples.ProtoExport" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add T2FGame.Samples.ProtoExport --version 1.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: T2FGame.Samples.ProtoExport, 1.0.4"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package T2FGame.Samples.ProtoExport@1.0.4
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=T2FGame.Samples.ProtoExport&version=1.0.4
#tool nuget:?package=T2FGame.Samples.ProtoExport&version=1.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
T2FGame.Samples.ProtoExport
演示如何使用 T2FGame.Tools 库从服务器程序集导出 .proto 文件。
前置条件
- 已安装 .NET 9 SDK
- 已构建 T2FGame.Samples.GameServer 项目
使用方法
1. 构建服务器项目
dotnet build ../T2FGame.Samples.GameServer -c Release
2. 运行示例
dotnet run
程序会自动:
- 读取 T2FGame.Samples.GameServer 程序集
- 提取嵌入的 .proto 文件内容
- 输出到
bin/Debug/net9.0/output/目录
代码说明
// 创建导出器
var exporter = new ProtoExporter();
// 执行导出
var result = exporter.Export(assemblyPath, outputDir);
if (result.Success)
{
Console.WriteLine($"导出成功!共 {result.FileCount} 个文件");
}
输出结果
执行后,输出目录将包含:
output/
├── messages.proto # 消息定义
├── user.proto # 用户模块消息
├── battle.proto # 战斗模块消息
└── chat.proto # 聊天模块消息
高级用法
导出所有嵌入资源
// 导出所有嵌入资源(包括 .proto 和其他文件)
var result = exporter.ExportAll(assemblyPath, outputDir);
使用 CLI 工具
也可以使用 T2FGame.Tools.Cli 命令行工具:
# 源码方式执行
dotnet run --project ../../src/T2FGame.Tools.Cli -- export \
-a ../../artifacts/bin/T2FGame.Samples.GameServer/Release/T2FGame.Samples.GameServer.dll \
-o ./output
# 或安装全局工具后执行
t2f-proto export -a ./MyGame.dll -o ./output
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- T2FGame.Tools (>= 1.0.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.