T2FGame.Samples.ProtoExport 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package T2FGame.Samples.ProtoExport --version 1.0.2
                    
NuGet\Install-Package T2FGame.Samples.ProtoExport -Version 1.0.2
                    
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.2" />
                    
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.2" />
                    
Directory.Packages.props
<PackageReference Include="T2FGame.Samples.ProtoExport" />
                    
Project file
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.2
                    
#r "nuget: T2FGame.Samples.ProtoExport, 1.0.2"
                    
#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.2
                    
#: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.2
                    
Install as a Cake Addin
#tool nuget:?package=T2FGame.Samples.ProtoExport&version=1.0.2
                    
Install as a Cake Tool

T2FGame.Samples.ProtoExport

演示如何使用 T2FGame.Tools 库从服务器程序集导出 .proto 文件。

前置条件

  1. 已安装 .NET 9 SDK
  2. 已构建 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 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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.9 419 12/11/2025
1.0.8 413 12/11/2025
1.0.7 409 12/11/2025
1.0.6 420 12/11/2025
1.0.5 425 12/10/2025
1.0.4 429 12/10/2025
1.0.3 430 12/9/2025
1.0.2 334 12/8/2025
0.0.1 341 12/8/2025