From 1662678ebf99b4f862b2f57a55fccfedf76393f4 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Wed, 28 Mar 2018 18:16:14 +0430 Subject: [PATCH 01/27] fixed line endings --- launcher/src/Resource.rc | Bin 3226 -> 1612 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/launcher/src/Resource.rc b/launcher/src/Resource.rc index 9d4ec33b65e2c0b97ed422a28fc9fc9ffad731e0..7f0b9067ebea6bd65c077946118a489e6ba96965 100644 GIT binary patch literal 1612 zcmcIkQE!_t5PnDEKiud`qgJrBzkq~UfogD{OtP-8<8U@cx_GJs+-5tD9PDQC`4T8$97Zn9r3AR_ZX*iB)+%R6X zeNDmoh}&DsG%!%phH(n+_jHr_VN$G#>nCyaTBNV5WfG-2f5vqx$8jJSDsDu#1GS~F zAupRS_M*%u@Gvy;M+XPSv59m2GnRJ5spkmD-_W=M9zgh8%j6brGtM-JsX{8{Vt_y% znPLrmIb4h|QHjR;P^UtVU5@SuK@o;(bZ@F88 zTC7~;95bzP{^RBROIvR!uaN>=Sobh413uS6D6BgE0S#WPO*k;Mg|<6TsUY;>N7?oi z_H9|Ab{Zzot2&@u_JTsW-?ywP6~jDsJ`07lD;bx7wq#OKt^mVj+k*Uw=1$_!g??Cg zE1#@&%cB)~Njx%#U(2@hTz~o&ndjB6rou)8F`r=fA8Ma@s*kds4)(y?%vb40F=ELs$zV~ej8NmI`Kd$AEcAN3Zi zkJdSEHzEJ#+*C>oID5#QC(L3V_85h%OzkWu3evrtnt6XcxRqNIG@jcFqAKK6kNg>s zU3GRI5nXMX^nRteqmq4ebcx{+QXS;a{H|@N9jF8PrjOG|34Bd-x5(9(_88qg_-ass z%pu2!)sWR80(6$+5up6I;v}!wweinkL4KCUm{70pDLy;SS>xnQj}zj}$J?Pj*c499 zddIs#(s}Rd?Vx(%;9Sv!TVsz;GjEOa^L@KQ-CDq-H$sYJusdZgOH>tQk7T5EPSacC z%Wic+A1a+JZh=5`UID6#UHDG57MyxLoZ{JEE3r?7m>u5qI-BfDJ#|c_79y=#4=W+g zkH_8L!S?+)DAqW}oDgD)pZ-_8{yF2GLWU@Rv#+!)#{K}T C28J2{ From a85cd81f00f684ac358f9e3b6ea6327c706265bd Mon Sep 17 00:00:00 2001 From: David Refoua Date: Wed, 28 Mar 2018 18:37:46 +0430 Subject: [PATCH 02/27] added version resources and manifest. --- launcher/src/Resource.rc | 51 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/launcher/src/Resource.rc b/launcher/src/Resource.rc index 7f0b906..ccbdeab 100644 --- a/launcher/src/Resource.rc +++ b/launcher/src/Resource.rc @@ -1,6 +1,14 @@ -// Microsoft Visual C++ generated resource script. -// +/* _ + ___ _ __ ___ __| | ___ _ __ + / __| '_ ` _ \ / _` |/ _ \ '__| +| (__| | | | | | (_| | __/ | + \___|_| |_| |_|\__,_|\___|_| +============================================================================= + The Cmder Console Emulator Project +*/ + #include "resource.h" +#include "version.rc2" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// @@ -54,6 +62,45 @@ IDI_CMDER ICON "..\\..\\icons\\cmder.ico" #endif // English (United States) resources ///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION CMDER_MAJOR_VERSION,CMDER_MINOR_VERSION,CMDER_REVISION_VERSION + PRODUCTVERSION CMDER_MAJOR_VERSION,CMDER_MINOR_VERSION,CMDER_REVISION_VERSION + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK + FILEFLAGS (CMDER_DEBUGFLAG | CMDER_BUILDFLAGS) + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE VFT2_UNKNOWN +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "100904b0" + BEGIN + VALUE "CompanyName", CMDER_COMPANY_NAME_STR "\0" + VALUE "FileDescription", CMDER_FILE_DESCRIPTION_STR "\0" + VALUE "FileVersion", CMDER_VERSION_STR "\0" + VALUE "InternalName", CMDER_INTERNAL_NAME_STR "\0" + VALUE "LegalCopyright", "Copyright (C) " CMDER_COPYRIGHT_YEAR_STR " " CMDER_COMPANY_NAME_STR "\0" + VALUE "OriginalFilename", CMDER_ORIGINAL_FILENAME_STR "\0" + VALUE "ProductName", CMDER_PRODUCT_NAME_STR "\0" + VALUE "ProductVersion", CMDER_VERSION_STR "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x1009, 1200 + END +END + +///////////////////////////////////////////////////////////////////////////// + +// Manifest +1 24 DISCARDABLE "Cmder.manifest" + #ifndef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // From dc9e385365bf60a80de3742f1fd022ac7529c1a9 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Wed, 28 Mar 2018 18:43:41 +0430 Subject: [PATCH 03/27] add cmder manifest file --- launcher/src/Cmder.manifest | 54 +++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 launcher/src/Cmder.manifest diff --git a/launcher/src/Cmder.manifest b/launcher/src/Cmder.manifest new file mode 100644 index 0000000..3352a4b --- /dev/null +++ b/launcher/src/Cmder.manifest @@ -0,0 +1,54 @@ + + + + + + Cmder Console Emulator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true/pm + + + + From 96736feecc288e577dc4d101bc0d41f0b4c1106f Mon Sep 17 00:00:00 2001 From: David Refoua Date: Wed, 28 Mar 2018 20:38:12 +0430 Subject: [PATCH 04/27] added version.rc2.sample this file controls how the version strings appears in the final compiled .exe file --- launcher/src/version.rc2.sample | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 launcher/src/version.rc2.sample diff --git a/launcher/src/version.rc2.sample b/launcher/src/version.rc2.sample new file mode 100644 index 0000000..cc6637d --- /dev/null +++ b/launcher/src/version.rc2.sample @@ -0,0 +1,22 @@ + +/** + * WARNING: do NOT modify this file! the content of this file should be + * automatically genereted before AppVeyor builds using the + * respective .ps1 Powershell scripts. + * + */ + +///////////////////////////////////////////////////////////////////////////// +// Define the version numbers and build information manually here: + +#define CMDER_MAJOR_VERSION {Cmder-Major-Version} +#define CMDER_MINOR_VERSION {Cmder-Minor-Version} +#define CMDER_REVISION_VERSION {Cmder-Revision-Version} + +#define CMDER_PRODUCT_NAME_STR "Cmder" +#define CMDER_FILE_DESCRIPTION_STR "Cmder: Lovely Console Emulator." +#define CMDER_INTERNAL_NAME_STR "Cmder" +#define CMDER_ORIGINAL_FILENAME_STR "Cmder.exe" +#define CMDER_COMPANY_NAME_STR "Samuel Vasko" +#define CMDER_COPYRIGHT_YEAR_STR "2016" +///////////////////////////////////////////////////////////////////////////// From f4321bbc33026e80df4228efce8ab4b8a66c3e89 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Wed, 28 Mar 2018 20:41:18 +0430 Subject: [PATCH 05/27] add functions to get version and generate rc these functions can be used to a) extract the version from `CHANGELOG.md` and b) create a .rc2 file from the `sample` template by replacing its content --- scripts/utils.ps1 | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/scripts/utils.ps1 b/scripts/utils.ps1 index e3a47fc..7474a58 100644 --- a/scripts/utils.ps1 +++ b/scripts/utils.ps1 @@ -62,6 +62,43 @@ function Digest-Hash($path) { return Invoke-Expression "md5sum $path" } +function Get-Version-Str($file) { + + # Define the regular expression to match the version string from changelog + [regex]$regex = '^## \[(?[\w\-\.]+)\]\([^\n()]+\)\s+\([^\n()]+\)$'; + + # Find the first match of the version string which means the latest version + $version = Select-String -Path $file -Pattern $regex | Select-Object -First 1 | % { $_.Matches.Groups[1].Value } + + return $version +} + +function Create-RC($version, $path) { + + if ( !(Test-Path "$path.sample") ) { + Write-Error "Invalid path provided for resources file." + return + } + + $resource = Get-Content -Path "$path.sample" + $pattern = @( "Cmder-Major-Version", "Cmder-Minor-Version", "Cmder-Revision-Version" ) + $index = 0 + + # Replace all non-numeric characters to dots and split to array + $version = $version -replace '[^0-9]+','.' -split '\.' + + foreach ($fragment in $version) { + if ( !$fragment ) { break } + elseif ($index -lt $pattern.length) { + $resource = $resource.Replace( "{" + $pattern[$index++] + "}", $fragment ) + } + } + + # Write the results + Set-Content -Path $path -Value $resource + +} + function Register-Cmder() { [CmdletBinding()] Param From eaf7048ed7ccc2dc3d25047679241ec095a1100f Mon Sep 17 00:00:00 2001 From: David Refoua Date: Wed, 28 Mar 2018 20:48:57 +0430 Subject: [PATCH 06/27] add automatic version creation with this commit, the build script extracts the latest version string found in `CHANGELOG.md`, and then creates appropriate resource files for the executable compilation --- scripts/build.ps1 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 62eb4e5..7a0cb07 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -64,6 +64,9 @@ $ErrorActionPreference = "Stop" Push-Location -Path $saveTo $sources = Get-Content $sourcesPath | Out-String | Convertfrom-Json +# Get the version string +$Version = Get-Version-Str ($PSScriptRoot + '\..\' + 'CHANGELOG.md') + # Check for requirements Ensure-Exists $sourcesPath Ensure-Executable "7z" @@ -116,6 +119,7 @@ Pop-Location if($Compile) { Push-Location -Path $launcher + Create-RC $Version ($launcher + '\src\version.rc2'); msbuild CmderLauncher.vcxproj /p:configuration=Release if ($LastExitCode -ne 0) { throw "msbuild failed to build the executable." From 249f7b9baf816945d0c3f0bb2133ee5293a2c975 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Wed, 28 Mar 2018 21:07:14 +0430 Subject: [PATCH 07/27] add build flags; use spaces --- launcher/src/version.rc2.sample | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/launcher/src/version.rc2.sample b/launcher/src/version.rc2.sample index cc6637d..4d32c9b 100644 --- a/launcher/src/version.rc2.sample +++ b/launcher/src/version.rc2.sample @@ -9,14 +9,17 @@ ///////////////////////////////////////////////////////////////////////////// // Define the version numbers and build information manually here: -#define CMDER_MAJOR_VERSION {Cmder-Major-Version} -#define CMDER_MINOR_VERSION {Cmder-Minor-Version} -#define CMDER_REVISION_VERSION {Cmder-Revision-Version} +#define CMDER_MAJOR_VERSION {Cmder-Major-Version} +#define CMDER_MINOR_VERSION {Cmder-Minor-Version} +#define CMDER_REVISION_VERSION {Cmder-Revision-Version} -#define CMDER_PRODUCT_NAME_STR "Cmder" -#define CMDER_FILE_DESCRIPTION_STR "Cmder: Lovely Console Emulator." -#define CMDER_INTERNAL_NAME_STR "Cmder" -#define CMDER_ORIGINAL_FILENAME_STR "Cmder.exe" -#define CMDER_COMPANY_NAME_STR "Samuel Vasko" -#define CMDER_COPYRIGHT_YEAR_STR "2016" +#define CMDER_PRODUCT_NAME_STR "Cmder" +#define CMDER_FILE_DESCRIPTION_STR "Cmder: Lovely Console Emulator." +#define CMDER_INTERNAL_NAME_STR "Cmder" +#define CMDER_ORIGINAL_FILENAME_STR "Cmder.exe" +#define CMDER_COMPANY_NAME_STR "Samuel Vasko" +#define CMDER_COPYRIGHT_YEAR_STR "2016" + +#define CMDER_DEBUGFLAG 0x0L // set to 0x1L to enable debug mode +#define CMDER_BUILDFLAGS 0x0L ///////////////////////////////////////////////////////////////////////////// From f8359fc3f78dc6221ae0122f3b6aa740dc282208 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Wed, 28 Mar 2018 21:11:31 +0430 Subject: [PATCH 08/27] add verbose version info --- scripts/build.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 7a0cb07..47f8626 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -124,6 +124,7 @@ if($Compile) { if ($LastExitCode -ne 0) { throw "msbuild failed to build the executable." } + else Write-Verbose "successfully built Cmder $Version!" Pop-Location } else { Write-Warning "You are not building a launcher, Use -Compile" From 018bf45df462f4ecc2d68309d5e3425acb3abd78 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Wed, 28 Mar 2018 21:13:55 +0430 Subject: [PATCH 09/27] add version string handler --- scripts/utils.ps1 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/utils.ps1 b/scripts/utils.ps1 index 7474a58..5cc6035 100644 --- a/scripts/utils.ps1 +++ b/scripts/utils.ps1 @@ -75,9 +75,10 @@ function Get-Version-Str($file) { function Create-RC($version, $path) { + $string = $version + if ( !(Test-Path "$path.sample") ) { - Write-Error "Invalid path provided for resources file." - return + throw "Invalid path provided for resources file." } $resource = Get-Content -Path "$path.sample" @@ -93,6 +94,9 @@ function Create-RC($version, $path) { $resource = $resource.Replace( "{" + $pattern[$index++] + "}", $fragment ) } } + + # Add the version string + $resource = $resource.Replace( "{Cmder-Version-Str}", $string ) # Write the results Set-Content -Path $path -Value $resource From 57a28f118d0bdb197d9272d8f723252039d26d93 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Wed, 28 Mar 2018 21:14:15 +0430 Subject: [PATCH 10/27] add template for version string --- launcher/src/version.rc2.sample | 1 + 1 file changed, 1 insertion(+) diff --git a/launcher/src/version.rc2.sample b/launcher/src/version.rc2.sample index 4d32c9b..e8eeefd 100644 --- a/launcher/src/version.rc2.sample +++ b/launcher/src/version.rc2.sample @@ -12,6 +12,7 @@ #define CMDER_MAJOR_VERSION {Cmder-Major-Version} #define CMDER_MINOR_VERSION {Cmder-Minor-Version} #define CMDER_REVISION_VERSION {Cmder-Revision-Version} +#define CMDER_VERSION_STR {Cmder-Version-Str} #define CMDER_PRODUCT_NAME_STR "Cmder" #define CMDER_FILE_DESCRIPTION_STR "Cmder: Lovely Console Emulator." From 3aeca3c97217cce5ce1657ba21ae8449dd0ed39e Mon Sep 17 00:00:00 2001 From: David Refoua Date: Wed, 28 Mar 2018 21:16:27 +0430 Subject: [PATCH 11/27] add required block to else statement --- scripts/build.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 47f8626..1c32bb0 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -124,7 +124,9 @@ if($Compile) { if ($LastExitCode -ne 0) { throw "msbuild failed to build the executable." } - else Write-Verbose "successfully built Cmder $Version!" + else { + Write-Verbose "successfully built Cmder $Version!" + } Pop-Location } else { Write-Warning "You are not building a launcher, Use -Compile" From ae473ecea699e11a690d799390c49c69e13ebea0 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Wed, 28 Mar 2018 21:24:02 +0430 Subject: [PATCH 12/27] add escaped quotes handling --- scripts/utils.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/utils.ps1 b/scripts/utils.ps1 index 5cc6035..c1d2400 100644 --- a/scripts/utils.ps1 +++ b/scripts/utils.ps1 @@ -91,7 +91,7 @@ function Create-RC($version, $path) { foreach ($fragment in $version) { if ( !$fragment ) { break } elseif ($index -lt $pattern.length) { - $resource = $resource.Replace( "{" + $pattern[$index++] + "}", $fragment ) + $resource = $resource.Replace( "{" + $pattern[$index++] + "}", '"' + $fragment + '"' ) } } From 2bc17c4ff2b13eb48e3184f7b8b2ef264b2a2cb2 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Wed, 28 Mar 2018 22:22:56 +0430 Subject: [PATCH 13/27] renamed app.manifest --- launcher/src/{Cmder.manifest => app.manifest} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename launcher/src/{Cmder.manifest => app.manifest} (100%) diff --git a/launcher/src/Cmder.manifest b/launcher/src/app.manifest similarity index 100% rename from launcher/src/Cmder.manifest rename to launcher/src/app.manifest From 1dadade661d72b2438dfbe1d9cb225d654878a12 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Wed, 28 Mar 2018 22:24:26 +0430 Subject: [PATCH 14/27] replaces spaces to tabs --- launcher/src/app.manifest | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/launcher/src/app.manifest b/launcher/src/app.manifest index 3352a4b..bf133f7 100644 --- a/launcher/src/app.manifest +++ b/launcher/src/app.manifest @@ -2,33 +2,33 @@ - + Cmder Console Emulator - - + + - - + + + level="asInvoker" + uiAccess="false" /> - - + + @@ -43,12 +43,12 @@ - - + + true/pm - + From cb4d95e7a3d59d515ec913d221fc23667208a3cd Mon Sep 17 00:00:00 2001 From: David Refoua Date: Wed, 28 Mar 2018 22:26:17 +0430 Subject: [PATCH 15/27] added build number, removed duplicated manifest --- launcher/src/Resource.rc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/launcher/src/Resource.rc b/launcher/src/Resource.rc index ccbdeab..fa9a64f 100644 --- a/launcher/src/Resource.rc +++ b/launcher/src/Resource.rc @@ -68,8 +68,8 @@ IDI_CMDER ICON "..\\..\\icons\\cmder.ico" // VS_VERSION_INFO VERSIONINFO - FILEVERSION CMDER_MAJOR_VERSION,CMDER_MINOR_VERSION,CMDER_REVISION_VERSION - PRODUCTVERSION CMDER_MAJOR_VERSION,CMDER_MINOR_VERSION,CMDER_REVISION_VERSION + FILEVERSION CMDER_MAJOR_VERSION,CMDER_MINOR_VERSION,CMDER_REVISION_VERSION,CMDER_BUILD_VERSION + PRODUCTVERSION CMDER_MAJOR_VERSION,CMDER_MINOR_VERSION,CMDER_REVISION_VERSION,CMDER_BUILD_VERSION FILEFLAGSMASK VS_FFI_FILEFLAGSMASK FILEFLAGS (CMDER_DEBUGFLAG | CMDER_BUILDFLAGS) FILEOS VOS_NT_WINDOWS32 @@ -98,9 +98,6 @@ END ///////////////////////////////////////////////////////////////////////////// -// Manifest -1 24 DISCARDABLE "Cmder.manifest" - #ifndef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // From 2f3f1d474a3d11a83ece1f78fc8164bde70d8bfa Mon Sep 17 00:00:00 2001 From: David Refoua Date: Wed, 28 Mar 2018 22:28:01 +0430 Subject: [PATCH 16/27] specified custom manifest file --- launcher/CmderLauncher.vcxproj | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/launcher/CmderLauncher.vcxproj b/launcher/CmderLauncher.vcxproj index 879bb5a..08deaeb 100644 --- a/launcher/CmderLauncher.vcxproj +++ b/launcher/CmderLauncher.vcxproj @@ -1,4 +1,4 @@ - + @@ -61,6 +61,9 @@ Windows true + + src/app.manifest %(AdditionalManifestFiles) + _USING_V110_SDK71_;%(PreprocessorDefinitions) @@ -84,6 +87,9 @@ true true + + src/app.manifest %(AdditionalManifestFiles) + copy $(TargetPath) $(SolutionDir)..\$(TargetFileName) From 236aefe8c6b9bd09ecac17ed6baa825fd25c5a2d Mon Sep 17 00:00:00 2001 From: David Refoua Date: Wed, 28 Mar 2018 22:28:33 +0430 Subject: [PATCH 17/27] add build version string --- launcher/src/version.rc2.sample | 1 + 1 file changed, 1 insertion(+) diff --git a/launcher/src/version.rc2.sample b/launcher/src/version.rc2.sample index e8eeefd..003621d 100644 --- a/launcher/src/version.rc2.sample +++ b/launcher/src/version.rc2.sample @@ -12,6 +12,7 @@ #define CMDER_MAJOR_VERSION {Cmder-Major-Version} #define CMDER_MINOR_VERSION {Cmder-Minor-Version} #define CMDER_REVISION_VERSION {Cmder-Revision-Version} +#define CMDER_BUILD_VERSION {Cmder-Build-Version} #define CMDER_VERSION_STR {Cmder-Version-Str} #define CMDER_PRODUCT_NAME_STR "Cmder" From c817df2032db7813a966627ab728710b563ed0b3 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Wed, 28 Mar 2018 22:30:09 +0430 Subject: [PATCH 18/27] add build version str; fix padding --- scripts/utils.ps1 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/utils.ps1 b/scripts/utils.ps1 index c1d2400..e98e83e 100644 --- a/scripts/utils.ps1 +++ b/scripts/utils.ps1 @@ -73,16 +73,16 @@ function Get-Version-Str($file) { return $version } -function Create-RC($version, $path) { +function Create-RC($string, $path) { - $string = $version + $version = $string + '.0.0.0.0' # padding for version string if ( !(Test-Path "$path.sample") ) { throw "Invalid path provided for resources file." } $resource = Get-Content -Path "$path.sample" - $pattern = @( "Cmder-Major-Version", "Cmder-Minor-Version", "Cmder-Revision-Version" ) + $pattern = @( "Cmder-Major-Version", "Cmder-Minor-Version", "Cmder-Revision-Version", "Cmder-Build-Version" ) $index = 0 # Replace all non-numeric characters to dots and split to array @@ -90,13 +90,13 @@ function Create-RC($version, $path) { foreach ($fragment in $version) { if ( !$fragment ) { break } - elseif ($index -lt $pattern.length) { - $resource = $resource.Replace( "{" + $pattern[$index++] + "}", '"' + $fragment + '"' ) + elseif ($index -le $pattern.length) { + $resource = $resource.Replace( "{" + $pattern[$index++] + "}", $fragment ) } } # Add the version string - $resource = $resource.Replace( "{Cmder-Version-Str}", $string ) + $resource = $resource.Replace( "{Cmder-Version-Str}", '"' + $string + '"' ) # Write the results Set-Content -Path $path -Value $resource From 624deec2f0f76c96301580b535c58ef949466cb6 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Wed, 28 Mar 2018 22:34:28 +0430 Subject: [PATCH 19/27] =?UTF-8?q?minor=20edit=20=E2=80=93=20added=20a=20ch?= =?UTF-8?q?aracter=20to=20the=20verbose=20output?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 1c32bb0..d4c201c 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -125,7 +125,7 @@ if($Compile) { throw "msbuild failed to build the executable." } else { - Write-Verbose "successfully built Cmder $Version!" + Write-Verbose "successfully built Cmder v$Version!" } Pop-Location } else { From 93d2c427ad4cda8ded2c0895b36bd8e32e3b0154 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Thu, 29 Mar 2018 01:18:57 +0430 Subject: [PATCH 20/27] respect powershell naming convention --- scripts/build.ps1 | 2 +- scripts/utils.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index d4c201c..099f857 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -65,7 +65,7 @@ Push-Location -Path $saveTo $sources = Get-Content $sourcesPath | Out-String | Convertfrom-Json # Get the version string -$Version = Get-Version-Str ($PSScriptRoot + '\..\' + 'CHANGELOG.md') +$Version = Get-VersionStr ($PSScriptRoot + '\..\' + 'CHANGELOG.md') # Check for requirements Ensure-Exists $sourcesPath diff --git a/scripts/utils.ps1 b/scripts/utils.ps1 index e98e83e..fc43d0e 100644 --- a/scripts/utils.ps1 +++ b/scripts/utils.ps1 @@ -62,7 +62,7 @@ function Digest-Hash($path) { return Invoke-Expression "md5sum $path" } -function Get-Version-Str($file) { +function Get-VersionStr($file) { # Define the regular expression to match the version string from changelog [regex]$regex = '^## \[(?[\w\-\.]+)\]\([^\n()]+\)\s+\([^\n()]+\)$'; From 3965852c262c8dd9e7f790fedad9229089884706 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Thu, 29 Mar 2018 03:23:18 +0430 Subject: [PATCH 21/27] clean before build --- scripts/build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 099f857..aa6eacd 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -120,7 +120,7 @@ Pop-Location if($Compile) { Push-Location -Path $launcher Create-RC $Version ($launcher + '\src\version.rc2'); - msbuild CmderLauncher.vcxproj /p:configuration=Release + msbuild CmderLauncher.vcxproj /t:Clean,Build /p:configuration=Release if ($LastExitCode -ne 0) { throw "msbuild failed to build the executable." } From b36b8a4cb379efc7d093f11ba0816978b5c145a3 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Fri, 30 Mar 2018 23:23:44 +0430 Subject: [PATCH 22/27] new version handle logic --- scripts/build.ps1 | 8 ++++---- scripts/pack.ps1 | 2 +- scripts/utils.ps1 | 42 ++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index aa6eacd..a3b9580 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -58,14 +58,14 @@ $ScriptRoot = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition $cmder_root = $ScriptRoot.replace("\scripts","") # Dot source util functions into this scope -. ".\utils.ps1" +. "$PSScriptRoot\utils.ps1" $ErrorActionPreference = "Stop" Push-Location -Path $saveTo $sources = Get-Content $sourcesPath | Out-String | Convertfrom-Json # Get the version string -$Version = Get-VersionStr ($PSScriptRoot + '\..\' + 'CHANGELOG.md') +$version = Get-VersionStr # Check for requirements Ensure-Exists $sourcesPath @@ -119,13 +119,13 @@ Pop-Location if($Compile) { Push-Location -Path $launcher - Create-RC $Version ($launcher + '\src\version.rc2'); + Create-RC $version ($launcher + '\src\version.rc2'); msbuild CmderLauncher.vcxproj /t:Clean,Build /p:configuration=Release if ($LastExitCode -ne 0) { throw "msbuild failed to build the executable." } else { - Write-Verbose "successfully built Cmder v$Version!" + Write-Verbose "successfully built Cmder v$version!" } Pop-Location } else { diff --git a/scripts/pack.ps1 b/scripts/pack.ps1 index 1b76a67..8382d5f 100644 --- a/scripts/pack.ps1 +++ b/scripts/pack.ps1 @@ -48,7 +48,7 @@ $targets = @{ Delete-Existing "..\Version*" Delete-Existing "..\build\*" -$version = Invoke-Expression "git describe --abbrev=0 --tags" +$version = Get-VersionStr (New-Item -ItemType file "$cmderRoot\Version $version") | Out-Null foreach ($t in $targets.GetEnumerator()) { diff --git a/scripts/utils.ps1 b/scripts/utils.ps1 index fc43d0e..ab7fec5 100644 --- a/scripts/utils.ps1 +++ b/scripts/utils.ps1 @@ -62,7 +62,45 @@ function Digest-Hash($path) { return Invoke-Expression "md5sum $path" } -function Get-VersionStr($file) { +function Get-VersionStr() { + + # Clear existing variable + Clear-Variable -name string + + # Determine if git is available + if (Get-Command "git.exe" -ErrorAction SilentlyContinue) + { + + # Determine if the current diesctory is a git repository + $GitPresent = Invoke-Expression "git rev-parse --is-inside-work-tree" -erroraction SilentlyContinue 2>$null + + if ( $GitPresent -eq 'true' ) + { + $string = Invoke-Expression "git describe --abbrev=0 --tags" + } + + } + + # Fallback used when Git is not available + if ( -not($string) ) + { + $string = Parse-Changelog ($PSScriptRoot + '\..\' + 'CHANGELOG.md') + } + + # Add build number, if AppVeyor is present + if ( $Env:APPVEYOR -eq 'True' ) + { + $string = $string + '.' + $Env:APPVEYOR_BUILD_NUMBER + } + + # Remove starting 'v' characters + $string = $string -replace '^v+','' # normalize version string + + return $string + +} + +function Parse-Changelog($file) { # Define the regular expression to match the version string from changelog [regex]$regex = '^## \[(?[\w\-\.]+)\]\([^\n()]+\)\s+\([^\n()]+\)$'; @@ -75,7 +113,7 @@ function Get-VersionStr($file) { function Create-RC($string, $path) { - $version = $string + '.0.0.0.0' # padding for version string + $version = $string + '.0.0.0.0' # padding for version string if ( !(Test-Path "$path.sample") ) { throw "Invalid path provided for resources file." From 502129d4f943d92e93465209038b486d83671a7d Mon Sep 17 00:00:00 2001 From: David Refoua Date: Fri, 30 Mar 2018 23:31:51 +0430 Subject: [PATCH 23/27] minor fix --- scripts/utils.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/utils.ps1 b/scripts/utils.ps1 index ab7fec5..c5a62cd 100644 --- a/scripts/utils.ps1 +++ b/scripts/utils.ps1 @@ -65,7 +65,7 @@ function Digest-Hash($path) { function Get-VersionStr() { # Clear existing variable - Clear-Variable -name string + if ($string) { Clear-Variable -name string } # Determine if git is available if (Get-Command "git.exe" -ErrorAction SilentlyContinue) From 5c3f46fd885ca5a2ac53f22521c7de9aa0baaf85 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Fri, 30 Mar 2018 23:46:48 +0430 Subject: [PATCH 24/27] fix git detection statement --- scripts/utils.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/utils.ps1 b/scripts/utils.ps1 index c5a62cd..a01f7dd 100644 --- a/scripts/utils.ps1 +++ b/scripts/utils.ps1 @@ -72,7 +72,7 @@ function Get-VersionStr() { { # Determine if the current diesctory is a git repository - $GitPresent = Invoke-Expression "git rev-parse --is-inside-work-tree" -erroraction SilentlyContinue 2>$null + $GitPresent = Invoke-Expression "git rev-parse --is-inside-work-tree" -erroraction SilentlyContinue if ( $GitPresent -eq 'true' ) { From 7d04ded1c278e3bbafc24d650b92940728a4b375 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Fri, 30 Mar 2018 23:52:32 +0430 Subject: [PATCH 25/27] add appveyor message --- scripts/build.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index a3b9580..07409a5 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -126,6 +126,9 @@ if($Compile) { } else { Write-Verbose "successfully built Cmder v$version!" + if ( $Env:APPVEYOR -eq 'True' ) { + Add-AppveyorMessage -Message "Building Cmder v$version was successfull." -Category Information + } } Pop-Location } else { From d6569192fc91167f555c3eff58402ff01f1197ea Mon Sep 17 00:00:00 2001 From: David Refoua Date: Fri, 30 Mar 2018 23:57:21 +0430 Subject: [PATCH 26/27] replace tabs to spaces --- scripts/utils.ps1 | 48 +++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/scripts/utils.ps1 b/scripts/utils.ps1 index a01f7dd..08d40d0 100644 --- a/scripts/utils.ps1 +++ b/scripts/utils.ps1 @@ -102,42 +102,42 @@ function Get-VersionStr() { function Parse-Changelog($file) { - # Define the regular expression to match the version string from changelog - [regex]$regex = '^## \[(?[\w\-\.]+)\]\([^\n()]+\)\s+\([^\n()]+\)$'; + # Define the regular expression to match the version string from changelog + [regex]$regex = '^## \[(?[\w\-\.]+)\]\([^\n()]+\)\s+\([^\n()]+\)$'; - # Find the first match of the version string which means the latest version - $version = Select-String -Path $file -Pattern $regex | Select-Object -First 1 | % { $_.Matches.Groups[1].Value } + # Find the first match of the version string which means the latest version + $version = Select-String -Path $file -Pattern $regex | Select-Object -First 1 | % { $_.Matches.Groups[1].Value } - return $version + return $version } function Create-RC($string, $path) { $version = $string + '.0.0.0.0' # padding for version string - if ( !(Test-Path "$path.sample") ) { - throw "Invalid path provided for resources file." - } + if ( !(Test-Path "$path.sample") ) { + throw "Invalid path provided for resources file." + } - $resource = Get-Content -Path "$path.sample" - $pattern = @( "Cmder-Major-Version", "Cmder-Minor-Version", "Cmder-Revision-Version", "Cmder-Build-Version" ) - $index = 0 + $resource = Get-Content -Path "$path.sample" + $pattern = @( "Cmder-Major-Version", "Cmder-Minor-Version", "Cmder-Revision-Version", "Cmder-Build-Version" ) + $index = 0 - # Replace all non-numeric characters to dots and split to array - $version = $version -replace '[^0-9]+','.' -split '\.' + # Replace all non-numeric characters to dots and split to array + $version = $version -replace '[^0-9]+','.' -split '\.' - foreach ($fragment in $version) { - if ( !$fragment ) { break } - elseif ($index -le $pattern.length) { - $resource = $resource.Replace( "{" + $pattern[$index++] + "}", $fragment ) - } - } - - # Add the version string - $resource = $resource.Replace( "{Cmder-Version-Str}", '"' + $string + '"' ) + foreach ($fragment in $version) { + if ( !$fragment ) { break } + elseif ($index -le $pattern.length) { + $resource = $resource.Replace( "{" + $pattern[$index++] + "}", $fragment ) + } + } + + # Add the version string + $resource = $resource.Replace( "{Cmder-Version-Str}", '"' + $string + '"' ) - # Write the results - Set-Content -Path $path -Value $resource + # Write the results + Set-Content -Path $path -Value $resource } From 94e7c24b72818c02d15c542f35b98f0d00041b01 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Sat, 31 Mar 2018 00:03:39 +0430 Subject: [PATCH 27/27] minor typo fix --- scripts/build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 07409a5..7a78a85 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -127,7 +127,7 @@ if($Compile) { else { Write-Verbose "successfully built Cmder v$version!" if ( $Env:APPVEYOR -eq 'True' ) { - Add-AppveyorMessage -Message "Building Cmder v$version was successfull." -Category Information + Add-AppveyorMessage -Message "Building Cmder v$version was successful." -Category Information } } Pop-Location