Skip to content

Commit 827d015

Browse files
committed
Feature: Installer version number auto-updates based on app version.
Work smart, not hard. :)
1 parent a893dfa commit 827d015

File tree

3 files changed

+52
-4
lines changed

3 files changed

+52
-4
lines changed

ShaderShrinker/InnoSetupProject/InstallScript.iss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[Setup]
55
AppId={{996B4B28-98DA-451F-ED15-8777E28DBDE4}
66
AppName={#MyAppName}
7-
AppVersion=0.3
7+
AppVersion=0.4
88
AppPublisher=Dean Edis
99
AppPublisherURL=https://github.com/deanthecoder/GLSLShaderShrinker
1010
DefaultDirName={commonpf}\ShaderShrinker
@@ -29,4 +29,4 @@ Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
2929
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
3030

3131
[Run]
32-
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
32+
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

ShaderShrinker/Shrinker.WpfApp/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@
4949
// You can specify all the values or you can default the Build and Revision Numbers
5050
// by using the '*' as shown below:
5151
// [assembly: AssemblyVersion("1.0.*")]
52-
[assembly: AssemblyVersion("0.3.0.0")]
53-
[assembly: AssemblyFileVersion("0.3.0.0")]
52+
[assembly: AssemblyVersion("0.4.0.0")]
53+
[assembly: AssemblyFileVersion("0.4.0.0")]
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// -----------------------------------------------------------------------
2+
// <copyright file="ReadmeBuInstallerVersionUpdater.cs">
3+
// Copyright (c) 2021 Dean Edis. All rights reserved.
4+
// </copyright>
5+
// <summary>
6+
// This example is provided on an "as is" basis and without warranty of any kind.
7+
// We do not warrant or make any representations regarding the use or
8+
// results of use of this example.
9+
// </summary>
10+
// -----------------------------------------------------------------------
11+
12+
using System.IO;
13+
using System.Linq;
14+
using System.Reflection;
15+
using NUnit.Framework;
16+
17+
namespace UnitTests
18+
{
19+
[TestFixture]
20+
public class ReadmeBuInstallerVersionUpdater
21+
{
22+
[Test]
23+
public void UpdateInstallerVersion()
24+
{
25+
var rootDir = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory;
26+
while (!rootDir.EnumerateFiles("*.md").Any())
27+
rootDir = rootDir.Parent;
28+
29+
// Get app version.
30+
var assemblyInfoFile = rootDir.EnumerateFiles("ShaderShrinker/Shrinker.WpfApp/Properties/AssemblyInfo.cs").First();
31+
var assemblyVersionLine = File.ReadAllLines(assemblyInfoFile.FullName).First(o => o.StartsWith("[assembly: AssemblyVersion("));
32+
var assemblyVersion = assemblyVersionLine.Substring(28).Replace(".0.0\")]", null);
33+
34+
// Open installer .iss.
35+
var issFile = rootDir.EnumerateFiles("InstallScript.iss", SearchOption.AllDirectories).FirstOrDefault();
36+
Assert.That(issFile, Is.Not.Null);
37+
var issLines = File.ReadAllLines(issFile.FullName);
38+
39+
for (var i = 0; i < issLines.Length; i++)
40+
{
41+
if (issLines[i].StartsWith("AppVersion="))
42+
issLines[i] = $"AppVersion={assemblyVersion}";
43+
}
44+
45+
File.WriteAllLines(issFile.FullName, issLines);
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)