- calculate full version tag in build script and set AssemblyTitle

- display AssemblyTitle in Vocaluxe gui
- code names are stored in .build/versionNames.json
- pre and post build scripts for windows (one place for all commands)
- adjusted and moved the linux build scripts
This commit is contained in:
lukeIam committed 2016-12-28 23:01:34 +01:00
1 parent 0eb28b1bc9
commit 152be5d8ad
9 files changed
+112 -64

No files matched your search

+1
View File
@@ -4,4 +4,5 @@ cd $PROJECT
sed -i -r -e 's/AssemblyInformationalVersion\(".*?"\)/AssemblyInformationalVersion("GITVERSION")/' $PROJECT/Properties/AssemblyInfo.cs
sed -i -r -e 's/AssemblyVersion\(".*?"\)/AssemblyVersion("SHORTVERSION")/' $PROJECT/Properties/AssemblyInfo.cs
sed -i -r -e 's/AssemblyFileVersion\(".*?"\)/AssemblyFileVersion("SHORTVERSION")/' $PROJECT/Properties/AssemblyInfo.cs
sed -i -r -e 's/AssemblyTitle\(".*?"\)/AssemblyTitle("FULLVERSION")/' $PROJECT/Properties/AssemblyInfo.cs
sed -i -e 's/var matchingServerVersion = "";/var matchingServerVersion = "'$(git describe --long)'";/' $PROJECT/../Output/Website/js/main.js
+29
View File
@@ -0,0 +1,29 @@
#!/bin/sh
PROJECT=$1
cd $PROJECT
arch=$2
version=$(git describe --long)
shortVersion=${version%%-*}
shortVersionClean=$(echo $shortVersion | sed -e 's/alpha/0/' -e 's/beta/1/' -e 's/rc/2/' -e 's/[[:alpha:]]//g')
case ${shortVersion##*.} in
alpha*)
releaseType='Alpha'
;;
beta*)
releaseType='Beta'
;;
rc*)
releaseType='RC'
;;
*)
releaseType='Release'
;;
esac
versionName=$(grep -oP "\"${shortVersionClean%.*}.\" *: *\"\K([^\"]+)(?=\")" ../.build/versionNames.json)
fullVersionName="Vocaluxe $([ "$versionName" == "" ] && echo "" || echo "'$versionName' ")$shortVersion ($arch) $([ "$releaseType" == "Release" ] && echo "" || echo "$releaseType ")($version)"
sed -i -e s/GITVERSION/$(git describe --long)/ $PROJECT/Properties/AssemblyInfo.cs
sed -i -e s/SHORTVERSION/"$shortVersionClean"/ $PROJECT/Properties/AssemblyInfo.cs
sed -i -e s/FULLVERSION/"$fullVersionName"/ $PROJECT/Properties/AssemblyInfo.cs
+5
View File
@@ -0,0 +1,5 @@
{
"0.0.": "Unversioned Build",
"0.3.": "Shining Heaven",
"0.4.": "Blue Sunrise"
}
+23
View File
@@ -0,0 +1,23 @@
param(
[Parameter(Mandatory=$true)]
[String]$ProjectDir
)
if($Env:GIT_VERSION_TAG)
{
$version = $Env:GIT_VERSION_TAG;
}
else
{
$version = git describe --long;
}
(Get-Content -Encoding UTF8 "$($ProjectDir)..\Output\Website\js\main.js") `
| Foreach-Object {$_ -replace '(?<=var *matchingServerVersion * = *\")\w*(?=\" *;)', "$version"} `
| Set-Content -Encoding UTF8 "$($ProjectDir)..\Output\Website\js\main.js"
(Get-Content -Encoding UTF8 "$($ProjectDir)Properties\AssemblyInfo.cs") `
| Foreach-Object {$_ -replace '(?<=AssemblyInformationalVersion\(\").*(?=\")', 'GITVERSION'} `
| Foreach-Object {$_ -replace '(?<=(AssemblyVersion|AssemblyFileVersion)\(\").*(?=\")', 'SHORTVERSION'} `
| Foreach-Object {$_ -replace '(?<=AssemblyTitle\(\").*(?=\")', 'FULLVERSION'} `
| Set-Content -Encoding UTF8 "$($ProjectDir)Properties\AssemblyInfo.cs"
+40
View File
@@ -0,0 +1,40 @@
param(
[Parameter(Mandatory=$true)]
[String]$ProjectDir,
[Parameter(Mandatory=$true)]
[String]$Arch
)
if($Env:GIT_VERSION_TAG)
{
$version = $Env:GIT_VERSION_TAG;
}
else
{
$version = git describe --long;
}
$shortVersion = $version.Split('-')[0];
[System.Reflection.Assembly]::LoadWithPartialName("System.Web.Extensions")
$versionName = (New-Object System.Web.Script.Serialization.JavaScriptSerializer).Deserialize((Get-Content "$($ProjectDir)..\.build\versionNames.json"), `
[System.Collections.Hashtable])[([regex]"[0-9]+\.[0-9]+\.").Match($shortVersion).Value]
$releaseType = switch -wildcard ($shortVersion.Split('.')[2])
{
"alpha*" {"Alpha"}
"beta*" {"Beta"}
"rc*" {"RC"}
default {"Release"}
};
$fullVersionName = "Vocaluxe $(if($versionName) {"'"+$versionName+"' "} else {''})$shortVersion ($Arch) $(if($releaseType -ne "Release") {'$releaseType '} else {''})($version)"
(Get-Content -Encoding UTF8 "$($ProjectDir)Properties\AssemblyInfo.cs") `
| Foreach-Object {$_ `
-replace '(?<=AssemblyInformationalVersion\(").*(?=")', $version `
-replace '(?<=(AssemblyVersion|AssemblyFileVersion)\(").*(?=")', `
($version.Split('-')[0].replace('alpha','0').replace('beta','1').replace('rc','2') -replace "[a-zA-Z]+","")`
-replace '(?<=AssemblyTitle\(").*(?=")', $fullVersionName `
-replace '(?<=AssemblyCopyright\(".*)[0-9]+(?=")', (Get-Date).Year} `
| Set-Content -Encoding UTF8 "$($ProjectDir)Properties\AssemblyInfo.cs"
+8 -51
View File
@@ -20,8 +20,10 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
using VocaluxeLib;
using VocaluxeLib.Xml;
namespace Vocaluxe.Base
{
@@ -35,6 +37,8 @@ namespace Vocaluxe.Base
// ReSharper restore UnusedMember.Global
}
/// <summary>
/// This class contains settings for the program
/// These are not editable, everything that can be changed by the user is in CConfig
@@ -52,26 +56,7 @@ namespace Vocaluxe.Base
//TODO: This should not be here as it can change
//State of the program
public static EProgramState ProgramState = EProgramState.Start;
//Adjusting of programName and version now in the assembly config.
private static readonly Dictionary<string,string> _CodeNames = new Dictionary<string, string>()
{
{"0.3.", "Shining Heaven"},
{"0.4.", "Blue Sunrise"}
};
private static string _ProgramCodeName
{
get
{
var versionParts = Application.ProductVersion.Split('.');
string name;
_CodeNames.TryGetValue($"{versionParts[0]}.{versionParts[1]}.", out name);
if (name != null)
return name;
return "Unnamed Version";
}
}
public static ERevision VersionRevision
{
@@ -208,6 +193,7 @@ namespace Vocaluxe.Base
{
get { return _Assembly.Name; }
}
private static string _Version
{
get
@@ -215,39 +201,10 @@ namespace Vocaluxe.Base
return Application.ProductVersion.Split('-').First();
}
}
private static string _GetVersionText()
{
string version = _Version + " (" + _Arch + ")";
string gitversion = Application.ProductVersion;
if (VersionRevision != ERevision.Release || gitversion.Split('-')[1] != "0")
{
version += " " + _GetVersionStatus() + String.Format(" ({0})", gitversion);
}
return version;
}
public static string GetFullVersionText()
{
string version = ProgramName;
if (_ProgramCodeName != "")
version += " \"" + _ProgramCodeName + "\"";
return version + " " + _GetVersionText();
}
private static string _GetVersionStatus()
{
string result = "";
if (VersionRevision != ERevision.Release)
result = Enum.GetName(typeof(ERevision), VersionRevision);
return result;
return ((AssemblyTitleAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false).First()).Title;
}
public static float GetRenderAspect()
-6
View File
@@ -1,6 +0,0 @@
#!/bin/sh
PROJECT=$1
cd $PROJECT
sed -i -e s/GITVERSION/$(git describe --long)/ $PROJECT/Properties/AssemblyInfo.cs
shortv=$(git describe --abbrev=0 | sed -e 's/alpha/0/' -e 's/beta/1/' -e 's/rc/2/')
sed -i -e s/SHORTVERSION/${shortv}/ $PROJECT/Properties/AssemblyInfo.cs
+1 -1
View File
@@ -22,7 +22,7 @@ using System.Runtime.InteropServices;
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die mit einer Assembly verknüpft sind.
[assembly: AssemblyTitle("Vocaluxe")]
[assembly: AssemblyTitle("FULLVERSION")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
+5 -6
View File
@@ -477,15 +477,14 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">xcopy /E /D /Y "$(ProjectDir)\Website" "$(SolutionDir)\PhoneGap"
powershell -command "if($Env:GIT_VERSION_TAG) {$version = $Env:GIT_VERSION_TAG;} else {$version = git describe --long;}(Get-Content -Encoding UTF8 '$(ProjectDir)..\Output\Website\js\main.js') | Foreach-Object {$_ -replace '(?&lt;=var *matchingServerVersion * = *\")\w*(?=\" *;)', "$version"} | Set-Content -Encoding UTF8 '$(ProjectDir)..\Output\Website\js\main.js'"
powershell -command "(Get-Content -Encoding UTF8 '$(ProjectDir)Properties\AssemblyInfo.cs') | Foreach-Object {$_ -replace '(?&lt;=AssemblyInformationalVersion\(\").*(?=\")', 'GITVERSION'} | Foreach-Object {$_ -replace '(?&lt;=(AssemblyVersion|AssemblyFileVersion)\(\").*(?=\")', 'SHORTVERSION'} | Set-Content -Encoding UTF8 '$(ProjectDir)Properties\AssemblyInfo.cs' "</PostBuildEvent>
<PostBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">xcopy /E /D /Y "$(ProjectDir)\Website" "$(SolutionDir)\PhoneGap"</PostBuildEvent>
<PostBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">powershell -ExecutionPolicy Bypass -File $(SolutionDir)\.build\winPostBuild.ps1 $(ProjectDir)</PostBuildEvent>
<PostBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">cp -ruT "$(ProjectDir)Website" "$(SolutionDir)/PhoneGap"</PostBuildEvent>
<PostBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">$(ProjectDir)Linux/Build/PostBuildEvent.sh $(ProjectDir)</PostBuildEvent>
<PostBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">$(SolutionDir)/.build/linuxPostBuildEvent.sh $(ProjectDir)</PostBuildEvent>
</PropertyGroup>
<PropertyGroup>
<PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">powershell -command " if($Env:GIT_VERSION_TAG) {$version = $Env:GIT_VERSION_TAG;} else {$version = git describe --long;} (Get-Content -Encoding UTF8 '$(ProjectDir)Properties\AssemblyInfo.cs') | Foreach-Object {$_ -replace '(?&lt;=AssemblyInformationalVersion\(\").*(?=\")', $version} | Foreach-Object {$_ -replace '(?&lt;=(AssemblyVersion|AssemblyFileVersion)\(\").*(?=\")', $version.Split('-')[0].replace('alpha','0').replace('beta','1').replace('rc','2')} | Foreach-Object {$_ -replace '(?&lt;=AssemblyCopyright\(\".*)[0-9]+(?=\")', (Get-Date).Year} | Set-Content -Encoding UTF8 '$(ProjectDir)Properties\AssemblyInfo.cs' "</PreBuildEvent>
<PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">$(ProjectDir)Linux/Build/PreBuildEvent.sh $(ProjectDir)</PreBuildEvent>
<PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">powershell -ExecutionPolicy Bypass -File $(SolutionDir)\.build\winPreBuild.ps1 $(ProjectDir) $(Platform)</PreBuildEvent>
<PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">$(SolutionDir)/.build/linuxPreBuildEvent.sh $(ProjectDir) $(Platform)</PreBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.