ARTICLE DETAIL

资讯详情

深耕网站建设与运营推广的一线实战洞察。

Unity 非后台,非自动构建,但统计报表 BuildReport ,构建自动化系统C#

Unity 非后台,非自动构建,但统计报表 BuildReport ,构建自动化系统C# 其实也非后台统计非完整系统这文章只是一个最小化的报表 Report 实现还是介绍啊一下这个项目- 一般的团队可能根本用不上帮忙分析一下这个项目有几个模块入门启动的步骤是https://github.com/chenfengyimei/AutomationUnityBuild/tree/masterAutomationUnityBuild 是一个基于.NET 8开发的开源自托管 Unity 全平台自动化构建与发布工具链旨在实现从代码仓库到应用商店的全链路闭环。其核心模块划分如下1. 核心构建与发布模块这是工具链的基础能力层按目标平台划分iOS 构建模块负责从 Git 同步代码驱动 Unity 导出 Xcode 工程再通过xcodebuild归档导出并自动上传至 App Store Connect / TestFlight。Android 构建模块支持构建并签名 APK / AAB 双格式包并能通过 API 直传 Google Play支持灰度发布比例配置。TikTok 小游戏模块独立模块负责构建 WebGL 包并通过 TikTok 开放平台 API 自动上传。2. 操作入口与协作模块提供了两种主要的使用方式以适应不同场景CLI命令行核心所有构建与上传能力的底层实现支持数字快捷指令、交互式配置向导和dry-run试运行环境检查适合脚本化集成。BuildServer网页端基于 CLI 能力扩展的多人协作层提供登录、项目与配置管理、任务队列、实时日志和产物下载等功能。DesktopApp桌面客户端基于 Avalonia UI 的 Windows 原生客户端支持离线配置管理与构建。看出来了么这个项目重点是重点是用 C# 开发的又跨平台又全链路的但是 C# 就是和我们常用启动方法很不同很卡手运行 :powershelldotnet run提示Hosting failed to start System.InvalidOperationException: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date. To generate a developer certificate run dotnet dev-certs https. To trust the certificate (Windows and macOS only) run dotnet dev-certs https --trust. For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid848054. at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions, Action1 configureOptions) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context, CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(ListenOptions[] listenOptions, AddressBindContext context, Func2 useHttps, CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.BindAsync(CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.StartAsync[TContext](IHttpApplication1 application, CancellationToken cancellationToken) at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken) at Microsoft.Extensions.Hosting.Internal.Host.StartAsyncb__15_1(IHostedService service, CancellationToken token) at Microsoft.Extensions.Hosting.Internal.Host.ForeachService[T](IEnumerable1 services, CancellationToken token, Boolean concurrent, Boolean abortOnFirstException, List1 exceptions, Func3 operation) fail: Microsoft.Extensions.Hosting.Internal.Host[9] BackgroundService failed System.Threading.Tasks.TaskCanceledException: A task was canceled. at BuildServer.Services.MaintenanceService.ExecuteAsync(CancellationToken stoppingToken) in F:\360Downloads\2027Unity\AutomationUnityBuild-master\BuildServer\Services\MaintenanceService.cs:line 30 at Microsoft.Extensions.Hosting.Internal.Host.TryExecuteBackgroundServiceAsync(BackgroundService backgroundService) Unhandled exception. crit: Microsoft.Extensions.Hosting.Internal.Host[10] The HostOptions.BackgroundServiceExceptionBehavior is configured to StopHost. A BackgroundService has thrown an unhandled exception, and the IHost instance is stopping. To avoid this behavior, configure this to Ignore; however the BackgroundService will not be restarted. System.Threading.Tasks.TaskCanceledException: A task was canceled. at BuildServer.Services.MaintenanceService.ExecuteAsync(CancellationToken stoppingToken) in F:\360DoSystem.InvalidOperationException: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date. To generate a developer certificate run dotnet dev-certs https. To trust the certificate (Windows and macOS only) run dotnet dev-certs https --trust. For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid848054. at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions, Action1 configureOptions) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context, CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(ListenOptions[] listenOptions, AddressBindContext context, Func2 useHttps, CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.BindAsync(CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.StartAsync[TContext](IHttpApplication1 application, CancellationToken cancellationToken) at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken) at Microsoft.Extensions.Hosting.Internal.Host.StartAsyncb__15_1(IHostedService service, CancellationToken token) at Microsoft.Extensions.Hosting.Internal.Host.ForeachService[T](IEnumerable1 services, CancellationToken token, Boolean concurrent, Boolean abortOnFirstException, List1 exceptions, Func3 operation) at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken) at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token) at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token) at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host) at Program.Main$(String[] args) in F:\360Downloads\2027Unity\AutomationUnityBuild-master\BuildServer\Program.cs:line 94 at Program.Main(String[] args)wnloads\2027Unity\AutomationUnityBuild-master\BuildServer\Services\MaintenanceService.cs:line 30 at Microsoft.Extensions.Hosting.Internal.Host.TryExecuteBackgroundServiceAsync(BackgroundService backgroundService)据说是证书问题万万没想到居然成功饿了第一步生成并信任开发证书最直接的方法在命令行中执行powershelldotnet dev-certs https --trustWindows 系统会弹出一个安全警告窗口点击“是”即可信任证书。如果提示“A valid HTTPS certificate is already present”说明证书已存在可能是过期或损坏需要执行第二步。第二步powershelldotnet run --urls http://localhost:5088dotnet run 执行了什么大概率是用了 WebApplication.CreateBuilder()下面这段AI写的但我真的一个字都删不了AI牛逼基于 BuildServer 的目录结构具体执行了这些文件1. 读取项目文件决定“怎么编译”BuildServer.csproj这是最核心的配置。dotnet run首先会找到它读取里面的目标框架如net8.0、引用的 NuGet 包、编译选项等。appsettings.json和appsettings.Development.json如果有虽然不参与编译但程序启动时会读取它们来加载配置比如端口、数据库连接字符串。dotnet run默认会设置环境为Development所以会优先加载appsettings.Development.json。2. 还原与编译生成可执行文件dotnet run会自动隐式执行dotnet restore和dotnet build。这个过程会根据.csproj下载缺失的 NuGet 包。把所有的.cs文件如你截图里的Program.cs、ApiRoutes.cs、Models.cs以及Services/、Security/等子目录里的所有 C# 文件编译成程序集。编译结果默认输出到bin/Debug/net8.0/目录下生成BuildServer.dll和BuildServer.exe。3. 启动程序真正“跑起来”编译成功后dotnet run会启动生成的BuildServer.dll。此时程序开始执行入口点Program.cs里的Main方法你日志里显示在第 94 行Run方法处崩溃。这是整个程序的起点它负责配置 Web 主机、注册服务、设置路由和中间件。后台服务Program.cs中注册的MaintenanceService等BackgroundService也会随之启动这就是你日志里第二个错误出现的地方。静态文件如果Program.cs里启用了UseStaticFiles那么wwwroot目录下的前端文件HTML、JS、CSS就会作为网页资源被提供。配置文件appsettings.json在启动时被读取用于配置 Kestrel 服务器比如监听哪个端口、是否启用 HTTPS。总结一下你执行dotnet run后它实际按顺序做了找BuildServer.csproj→ 2.还原NuGet 包 → 3.编译所有.cs文件 → 4.生成bin/Debug/net8.0/BuildServer.dll→ 5.运行这个 DLL从Program.cs的Main开始读取appsettings.json启动 Web 服务器和后台服务。接入了一个报表《不是很复杂》但是过程就不贴出来了结果如下参考 - 无厘头《无什么用参考》优化 IL2CPP 构建时间 - Unity 手册几个占用时长占用分类分别是IL2CPPBuild Native Unity binaryExporting projectBuilding Gradle参考开源项目GitHub - chenfengyimei/AutomationUnityBuild: A full-platform automated build and release toolchain for Unity — closing the loop from source repository to app store. Covers iOS, Android, and TikTok build pipelines with direct uploads to App Store Connect / TestFlight / Google Play / TikTok Open Platform; ships with CLI, BuildServer web console, and LinuxGateway multi-node scheduling. · GitHub
返回列表