Skip to content

Commit

Permalink
Add notices for development builds (#578)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* 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 <[email protected]>
Co-authored-by: Kerbiter <[email protected]>
  • Loading branch information
3 people authored Dec 6, 2024
1 parent 9bee9dc commit 248a551
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 15 deletions.
5 changes: 5 additions & 0 deletions ClientCore/ClientConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,11 @@ public IEnumerable<string> SupplementalMapFileExtensions
/// </summary>
public bool DisallowJoiningIncompatibleGames => clientDefinitionsIni.GetBooleanValue(SETTINGS, nameof(DisallowJoiningIncompatibleGames), false);

/// <summary>
/// Activates warnings for development builds of XNA Client
/// </summary>
public bool ShowDevelopmentBuildWarnings => clientDefinitionsIni.GetBooleanValue(SETTINGS, nameof(ShowDevelopmentBuildWarnings), true);

#endregion

#region Network definitions
Expand Down
2 changes: 1 addition & 1 deletion ClientUpdater/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/// <summary>
Expand Down
9 changes: 9 additions & 0 deletions DXMainClient/DXGUI/GameClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
19 changes: 18 additions & 1 deletion DXMainClient/DXGUI/Multiplayer/CnCNet/CnCNetLobby.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 12 additions & 2 deletions DXMainClient/PreStartup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions DXMainClient/Resources/ClientDefinitions.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<Product>CnCNet Client</Product>
<Copyright>Copyright © CnCNet, Rampastring 2011-2024</Copyright>
<Trademark>CnCNet</Trademark>
<!-- GitVersion will rewrite the informational version anyway -->
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
</PropertyGroup>

<PropertyGroup>
Expand Down
8 changes: 8 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
<Message Importance="high" Text="Engine: $(Engine); Game: $(Game); Platform: $(Platform); TargetFramework: $(TargetFramework); Configuration: $(Configuration)" />
</Target>

<!-- "GetVersion" target is defined in GitVersion package -->
<Target Name="NonReleaseBuildWarning" AfterTargets="GetVersion" BeforeTargets="CoreCompile" Condition="'$(MSBuildProjectName)' == 'DXMainClient' AND ($(GitVersion_CommitsSinceVersionSource) != 0 OR $(GitVersion_BranchName) != 'master')">
<PropertyGroup>
<DefineConstants>$(DefineConstants);DEVELOPMENT_BUILD</DefineConstants>
</PropertyGroup>
<Warning Text="This is a development build of the client. Stability and reliability may not be fully guaranteed." Condition="'$(BuildingInsideVisualStudio)' != 'true'"></Warning>
</Target>

<Target Name="RestoreUpdater" AfterTargets="Restore" Condition="'$(PublishDir)' != '' AND '$(MSBuildProjectName)' == 'DXMainClient'">
<MSBuild
Projects="$(MSBuildThisFileDirectory)SecondStageUpdater\SecondStageUpdater.csproj"
Expand Down
19 changes: 9 additions & 10 deletions GitVersion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,22 @@
# This configuration will allow the gitversion msbuild task to auto version our executable. It uses existing tags
# to determine the next version by auto incrementing the Minor, Patch, or Tag version. The Tag version is calculated
# by counting the number of commits since the last tag.
# Minor version is incremented by 1 when a build is created from the develop branch.
# Patch version is incremented by 1 when a build is created from the master branch.
# Patch version is incremented by 1 when a build is created from the develop or master branch.
#
# Examples:
#
# Latest tag is "2.8.0" -
# The next commit on develop branch will start version 2.9.0-beta.1.
# That increments the Minor by 1. That also increments the beta by 1 for the 1 additional commit.
# Another commit creates 2.9.0-beta.2 and so on.
# The next commit on develop branch will start version 2.8.1-beta.1.
# That increments the Patch by 1. That also increments the beta by 1 for the 1 additional commit.
# Another commit creates 2.8.1-beta.2 and so on.
#
# Latest tag is "2.8.0-beta.1" -
# The next commit on develop branch is "2.8.0-beta.2". Minor version is NOT incremented, because the
# The next commit on develop branch is "2.8.0-beta.2". Patch version is NOT incremented, because the
# base tag of "2.8.0-beta.1" is also a beta.
#
# Latest tag is "2.8.0" -
# A new commit is added directly to master. The new version is "2.8.1".
# That increments th Patch, because it is treated as a "hotfix" directly on master.
# A new commit is added directly to master. The new version is "2.8.1-rc.1".
# That increments the Patch, because it is treated as a "hotfix" directly on master.
#
# Versioning Modes Quick View:
#
Expand All @@ -37,11 +36,11 @@ branches:
increment: Patch
is-mainline: true
source-branches: [ 'develop' ]
tag: ''
tag: rc

develop:
regex: ^develop$
increment: Minor
increment: Patch
is-mainline: false
mode: ContinuousDeployment
tag: beta
2 changes: 1 addition & 1 deletion SecondStageUpdater/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private static void Main(string[] args)
Logger.WriteLogFile = true;
Logger.WriteToConsole = false;
Logger.Log("CnCNet Client Second-Stage Updater");
Logger.Log("Version: " + Assembly.GetAssembly(typeof(Program)).GetName().Version);
Logger.Log("Version: " + GitVersionInformation.AssemblySemVer);
Write("Base directory: " + baseDirectory.FullName);
Write($"Waiting for the client ({clientExecutable}) to exit..");

Expand Down

0 comments on commit 248a551

Please sign in to comment.