From 248a551e39ef2cc0d61881d7e2ea56ab8b84d6cf Mon Sep 17 00:00:00 2001 From: SadPencil Date: Fri, 6 Dec 2024 10:53:37 +0800 Subject: [PATCH] Add notices for development builds (#578) * Add notice for non-release builds * Show non-release notice in CnCNet lobby * Improved non-release build detection * Specify IncludeSourceRevisionInInformationalVersion * Add ThisAssembly.Git * Show Git branch and commit id as the non-release version string * Update the version string for non-release builds * Update the warning message * Localize develop build title * Add ShowDevelopmentBuildWarnings option * Update Directory.Build.targets * Add `ShowDevelopmentBuildWarnings` key into `Settings` section * Update GameClass.cs Co-authored-by: Kerbiter * Update Directory.Build.targets * Remove ThisAssembly.Git package * Replace assembly version with GitVersionInformation * Increase Patch version even for develop branch since we are not following SemVer right now * Use GitVersionInformation.AssemblySemVer * Empty commit to workaround a GitHub bug * non-release build -> development build --------- Co-authored-by: MahBoiDeveloper Co-authored-by: Kerbiter --- ClientCore/ClientConfiguration.cs | 5 +++++ ClientUpdater/Updater.cs | 2 +- DXMainClient/DXGUI/GameClass.cs | 9 +++++++++ .../DXGUI/Multiplayer/CnCNet/CnCNetLobby.cs | 19 ++++++++++++++++++- DXMainClient/PreStartup.cs | 14 ++++++++++++-- DXMainClient/Resources/ClientDefinitions.ini | 4 ++++ Directory.Build.props | 2 ++ Directory.Build.targets | 8 ++++++++ GitVersion.yml | 19 +++++++++---------- SecondStageUpdater/Program.cs | 2 +- 10 files changed, 69 insertions(+), 15 deletions(-) diff --git a/ClientCore/ClientConfiguration.cs b/ClientCore/ClientConfiguration.cs index 1bbc27258..cccd36eb3 100644 --- a/ClientCore/ClientConfiguration.cs +++ b/ClientCore/ClientConfiguration.cs @@ -389,6 +389,11 @@ public IEnumerable SupplementalMapFileExtensions /// public bool DisallowJoiningIncompatibleGames => clientDefinitionsIni.GetBooleanValue(SETTINGS, nameof(DisallowJoiningIncompatibleGames), false); + /// + /// Activates warnings for development builds of XNA Client + /// + public bool ShowDevelopmentBuildWarnings => clientDefinitionsIni.GetBooleanValue(SETTINGS, nameof(ShowDevelopmentBuildWarnings), true); + #endregion #region Network definitions diff --git a/ClientUpdater/Updater.cs b/ClientUpdater/Updater.cs index c369ca83f..dd606a689 100644 --- a/ClientUpdater/Updater.cs +++ b/ClientUpdater/Updater.cs @@ -410,7 +410,7 @@ internal static void UpdateUserAgent(HttpClient httpClient) if (UpdaterVersion != "N/A") httpClient.DefaultRequestHeaders.UserAgent.Add(new(nameof(Updater), UpdaterVersion)); - httpClient.DefaultRequestHeaders.UserAgent.Add(new("Client", Assembly.GetEntryAssembly().GetName().Version.ToString())); + httpClient.DefaultRequestHeaders.UserAgent.Add(new("Client", GitVersionInformation.AssemblySemVer)); } /// diff --git a/DXMainClient/DXGUI/GameClass.cs b/DXMainClient/DXGUI/GameClass.cs index fcff5dd14..25df2e507 100644 --- a/DXMainClient/DXGUI/GameClass.cs +++ b/DXMainClient/DXGUI/GameClass.cs @@ -69,6 +69,15 @@ protected override void Initialize() Window.Title = string.IsNullOrEmpty(windowTitle) ? string.Format("{0} Client", MainClientConstants.GAME_NAME_SHORT) : windowTitle; + { + string developBuildTitle = "Development Build".L10N("Client:Main:DevelopmentBuildTitle"); + +#if DEVELOPMENT_BUILD + if (ClientConfiguration.Instance.ShowDevelopmentBuildWarnings) + Window.Title += $" ({developBuildTitle})"; +#endif + } + base.Initialize(); AssetLoader.Initialize(GraphicsDevice, content); diff --git a/DXMainClient/DXGUI/Multiplayer/CnCNet/CnCNetLobby.cs b/DXMainClient/DXGUI/Multiplayer/CnCNet/CnCNetLobby.cs index 2a7ff5a8b..36aa56586 100644 --- a/DXMainClient/DXGUI/Multiplayer/CnCNet/CnCNetLobby.cs +++ b/DXMainClient/DXGUI/Multiplayer/CnCNet/CnCNetLobby.cs @@ -556,10 +556,27 @@ private void PostUIInit() gameCreationPanel.Hide(); + string clientVersion = GitVersionInformation.AssemblySemVer; +#if DEVELOPMENT_BUILD + clientVersion = $"{GitVersionInformation.CommitDate} {GitVersionInformation.BranchName}@{GitVersionInformation.ShortSha}"; +#endif + connectionManager.MainChannel.AddMessage(new ChatMessage(Color.White, Renderer.GetSafeString( - string.Format("*** DTA CnCNet Client version {0} ***".L10N("Client:Main:CnCNetClientVersionMessage"), Assembly.GetAssembly(typeof(CnCNetLobby)).GetName().Version), + string.Format("*** DTA CnCNet Client version {0} ***".L10N("Client:Main:CnCNetClientVersionMessage"), clientVersion), lbChatMessages.FontIndex))); + { + string developBuildWarningMessage = "This is a development build of the client. Stability and reliability may not be fully guaranteed.".L10N("Client:Main:DevelopmentBuildWarning"); + +#if DEVELOPMENT_BUILD + if (ClientConfiguration.Instance.ShowDevelopmentBuildWarnings) + { + connectionManager.MainChannel.AddMessage(new ChatMessage(Color.Red, Renderer.GetSafeString( + developBuildWarningMessage, lbChatMessages.FontIndex))); + } +#endif + } + connectionManager.BannedFromChannel += ConnectionManager_BannedFromChannel; loginWindow = new CnCNetLoginWindow(WindowManager); diff --git a/DXMainClient/PreStartup.cs b/DXMainClient/PreStartup.cs index 955288586..a5ea0a603 100644 --- a/DXMainClient/PreStartup.cs +++ b/DXMainClient/PreStartup.cs @@ -90,8 +90,18 @@ public static void Initialize(StartupParams parameters) MainClientConstants.Initialize(); Logger.Log("***Logfile for " + MainClientConstants.GAME_NAME_LONG + " client***"); - Logger.Log("Client version: " + Assembly.GetAssembly(typeof(PreStartup)).GetName().Version); - Logger.Log(FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductVersion); + + string clientVersion = GitVersionInformation.AssemblySemVer; +#if DEVELOPMENT_BUILD + clientVersion = $"{GitVersionInformation.CommitDate} {GitVersionInformation.BranchName}@{GitVersionInformation.ShortSha}"; +#endif + + Logger.Log($"Client version: {clientVersion}"); + Logger.Log(GitVersionInformation.InformationalVersion); + +#if DEVELOPMENT_BUILD + Logger.Log("This is a development build of the client. Stability and reliability may not be fully guaranteed."); +#endif // Log information about given startup params if (parameters.NoAudio) diff --git a/DXMainClient/Resources/ClientDefinitions.ini b/DXMainClient/Resources/ClientDefinitions.ini index 70f1fd571..b9a33216b 100644 --- a/DXMainClient/Resources/ClientDefinitions.ini +++ b/DXMainClient/Resources/ClientDefinitions.ini @@ -106,3 +106,7 @@ Quickmatch=CnCNetQM.exe ; Set to true to disable the updater and to hide the "cheater!" dialog when modding the game ModMode=true + +; Activates warnings for non-release build of XNA Client. +; Please, make sure you are not publishing stable mod version with unstable development client build. +ShowDevelopmentBuildWarnings=true \ No newline at end of file diff --git a/Directory.Build.props b/Directory.Build.props index 597d88bd5..c6b5befbd 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -10,6 +10,8 @@ CnCNet Client Copyright © CnCNet, Rampastring 2011-2024 CnCNet + + false diff --git a/Directory.Build.targets b/Directory.Build.targets index 3c8ae2f97..479cc2f14 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -3,6 +3,14 @@ + + + + $(DefineConstants);DEVELOPMENT_BUILD + + + +