Added Beta build configuration and added CommitInfo class

This commit is contained in:
miku-666
2023-05-02 16:43:15 +02:00
parent 27f57870d8
commit ca298ed5be
4 changed files with 86 additions and 39 deletions

View File

@@ -71,8 +71,11 @@ namespace PckStudio
labelVersion.Text = "PCK Studio: " + Application.ProductVersion;
ChangelogRichTextBox.Text = Resources.CHANGELOG;
#if BETA
labelVersion.Text += $"{Program.Info.BetaBuildVersion}";
#endif
#if DEBUG
labelVersion.Text += $" (Debug build: {Program.Info.BuildVersion}@{Program.Info.LastCommitHash})";
labelVersion.Text += $" (Debug build: {CommitInfo.BranchName}@{CommitInfo.CommitHash})";
#endif
pckFileTypeHandler = new Dictionary<PckFile.FileData.FileType, Action<PckFile.FileData>>(15)

View File

@@ -18,39 +18,40 @@
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<Target Name="GetGitHash" BeforeTargets="WriteGitHash" Condition="'$(BuildHash)' == ''">
<PropertyGroup>
<!-- temp file for the git version (lives in "obj" folder)-->
<VerFile>$(IntermediateOutputPath)gitver</VerFile>
</PropertyGroup>
<!-- write the hash to the temp file.-->
<Exec Command="git -C $(ProjectDir) describe --always &gt; $(VerFile)" />
<!-- read the version into the GitVersion itemGroup-->
<ReadLinesFromFile File="$(VerFile)">
<Output TaskParameter="Lines" ItemName="GitVersion" />
</ReadLinesFromFile>
<!-- Set the BuildHash property to contain the GitVersion, if it wasn't already set.-->
<PropertyGroup>
<BuildHash>@(GitVersion)</BuildHash>
</PropertyGroup>
<Target Name="GetGitHash" BeforeTargets="WriteGitInfo" Condition="'$(BuildHash)' == ''">
<!-- write hash and branch to console.-->
<Exec Command="git -C $(ProjectDir) describe --always" ConsoleToMsBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="GitHash" />
</Exec>
<Exec Command="git -C $(ProjectDir) branch --show-current" ConsoleToMsBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="GitBranch" />
</Exec>
<PropertyGroup>
<BuildHash>$(GitHash)</BuildHash>
<BuildBranch>$(GitBranch)</BuildBranch>
</PropertyGroup>
</Target>
<Target Name="WriteGitHash" BeforeTargets="CoreCompile">
<!-- names the obj/.../GitAssemblyInfo.cs file -->
<Target Name="WriteGitInfo" BeforeTargets="CoreCompile">
<!-- names the obj/.../GitAssemblyInfo.cs file -->
<PropertyGroup>
<GitAssemblyInfoFile>$(IntermediateOutputPath)GitAssemblyInfo.cs</GitAssemblyInfoFile>
</PropertyGroup>
<!-- includes the GitAssemblyInfo for compilation into your project -->
<!-- includes the GitAssemblyInfo for compilation into your project -->
<ItemGroup>
<Compile Include="$(GitAssemblyInfoFile)" />
</ItemGroup>
<!-- defines the AssemblyMetadata attribute that will be written -->
<!-- defines the AssemblyMetadata attribute that will be written -->
<ItemGroup>
<AssemblyAttributes Include="AssemblyMetadata">
<_Parameter1>GitHash</_Parameter1>
<_Parameter2>$(BuildHash)</_Parameter2>
</AssemblyAttributes>
<AssemblyAttributes Include="AssemblyMetadata">
<_Parameter1>GitBranch</_Parameter1>
<_Parameter2>$(BuildBranch)</_Parameter2>
</AssemblyAttributes>
</ItemGroup>
<!-- writes the attribute to the GitAssemblyInfo file -->
<!-- writes the attribute to the GitAssemblyInfo file -->
<WriteCodeFragment Language="C#" OutputFile="$(GitAssemblyInfoFile)" AssemblyAttributes="@(AssemblyAttributes)" />
</Target>
<PropertyGroup>
@@ -82,14 +83,24 @@
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>false</Optimize>
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Beta|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Beta\</OutputPath>
<DefineConstants>BETA;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>Resources\PCK-Studio_Logo.ico</ApplicationIcon>
</PropertyGroup>
@@ -124,16 +135,6 @@
<ManifestKeyFile>
</ManifestKeyFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleasePortable|AnyCPU'">
<OutputPath>bin\ReleasePortable\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<LangVersion>preview</LangVersion>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup />
<PropertyGroup>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>

View File

@@ -15,7 +15,7 @@ namespace PckStudio
private System.Globalization.Calendar BuildCalendar = new System.Globalization.CultureInfo("en-US").Calendar;
private DateTime date = new FileInfo(Assembly.GetExecutingAssembly().Location).LastWriteTime;
public string BuildVersion
public string BetaBuildVersion
{
get
{
@@ -27,12 +27,34 @@ namespace PckStudio
BuildType);
}
}
}
public string LastCommitHash =>
Assembly
.GetEntryAssembly()
.GetCustomAttributes<AssemblyMetadataAttribute>()
.FirstOrDefault(attr => attr.Key == "GitHash")?.Value;
static class CommitInfo
{
private static string _branchName = null;
private static string _commitHash = null;
public static string BranchName
{
get
{
return _branchName ??= Assembly
.GetEntryAssembly()
.GetCustomAttributes<AssemblyMetadataAttribute>()
.FirstOrDefault(attr => attr.Key == "GitBranch")?.Value;
}
}
public static string CommitHash
{
get
{
return _commitHash ??= Assembly
.GetEntryAssembly()
.GetCustomAttributes<AssemblyMetadataAttribute>()
.FirstOrDefault(attr => attr.Key == "GitHash")?.Value;
}
}
}
static class Program

View File

@@ -13,6 +13,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpMss32", "Vendor\SharpM
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Beta|Any CPU = Beta|Any CPU
Beta|x64 = Beta|x64
Beta|x86 = Beta|x86
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
@@ -21,6 +24,12 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0ACAAEDE-93F5-4B5D-B8D7-A0C43359C0D6}.Beta|Any CPU.ActiveCfg = Beta|Any CPU
{0ACAAEDE-93F5-4B5D-B8D7-A0C43359C0D6}.Beta|Any CPU.Build.0 = Beta|Any CPU
{0ACAAEDE-93F5-4B5D-B8D7-A0C43359C0D6}.Beta|x64.ActiveCfg = Beta|Any CPU
{0ACAAEDE-93F5-4B5D-B8D7-A0C43359C0D6}.Beta|x64.Build.0 = Beta|Any CPU
{0ACAAEDE-93F5-4B5D-B8D7-A0C43359C0D6}.Beta|x86.ActiveCfg = Beta|Any CPU
{0ACAAEDE-93F5-4B5D-B8D7-A0C43359C0D6}.Beta|x86.Build.0 = Beta|Any CPU
{0ACAAEDE-93F5-4B5D-B8D7-A0C43359C0D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0ACAAEDE-93F5-4B5D-B8D7-A0C43359C0D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0ACAAEDE-93F5-4B5D-B8D7-A0C43359C0D6}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -33,6 +42,12 @@ Global
{0ACAAEDE-93F5-4B5D-B8D7-A0C43359C0D6}.Release|x64.Build.0 = Release|Any CPU
{0ACAAEDE-93F5-4B5D-B8D7-A0C43359C0D6}.Release|x86.ActiveCfg = Release|Any CPU
{0ACAAEDE-93F5-4B5D-B8D7-A0C43359C0D6}.Release|x86.Build.0 = Release|Any CPU
{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB}.Beta|Any CPU.ActiveCfg = Release|Any CPU
{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB}.Beta|Any CPU.Build.0 = Release|Any CPU
{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB}.Beta|x64.ActiveCfg = Release|Any CPU
{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB}.Beta|x64.Build.0 = Release|Any CPU
{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB}.Beta|x86.ActiveCfg = Release|Any CPU
{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB}.Beta|x86.Build.0 = Release|Any CPU
{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -45,6 +60,12 @@ Global
{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB}.Release|x64.Build.0 = Release|Any CPU
{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB}.Release|x86.ActiveCfg = Release|Any CPU
{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB}.Release|x86.Build.0 = Release|Any CPU
{E8D0B671-3AB1-48B6-A767-58DF67BD5D11}.Beta|Any CPU.ActiveCfg = Release|Any CPU
{E8D0B671-3AB1-48B6-A767-58DF67BD5D11}.Beta|Any CPU.Build.0 = Release|Any CPU
{E8D0B671-3AB1-48B6-A767-58DF67BD5D11}.Beta|x64.ActiveCfg = Release|Any CPU
{E8D0B671-3AB1-48B6-A767-58DF67BD5D11}.Beta|x64.Build.0 = Release|Any CPU
{E8D0B671-3AB1-48B6-A767-58DF67BD5D11}.Beta|x86.ActiveCfg = Release|Any CPU
{E8D0B671-3AB1-48B6-A767-58DF67BD5D11}.Beta|x86.Build.0 = Release|Any CPU
{E8D0B671-3AB1-48B6-A767-58DF67BD5D11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E8D0B671-3AB1-48B6-A767-58DF67BD5D11}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E8D0B671-3AB1-48B6-A767-58DF67BD5D11}.Debug|x64.ActiveCfg = Debug|Any CPU