diff --git a/.gitignore b/.gitignore
index 9491a2f..0af7d09 100644
--- a/.gitignore
+++ b/.gitignore
@@ -184,7 +184,7 @@ publish/
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
-*.pubxml
+# *.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
@@ -360,4 +360,7 @@ MigrationBackup/
.ionide/
# Fody - auto-generated XML schema
-FodyWeavers.xsd
\ No newline at end of file
+FodyWeavers.xsd
+
+# built and packaged releases
+*.zip
diff --git a/Pro7ChordEditor/App.config b/Pro7ChordEditor/App.config
index 56efbc7..83858e1 100644
--- a/Pro7ChordEditor/App.config
+++ b/Pro7ChordEditor/App.config
@@ -1,6 +1,4 @@
-
-
-
-
\ No newline at end of file
+
+
diff --git a/Pro7ChordEditor/MainWindow.xaml.cs b/Pro7ChordEditor/MainWindow.xaml.cs
index 587b9b7..ce1342c 100644
--- a/Pro7ChordEditor/MainWindow.xaml.cs
+++ b/Pro7ChordEditor/MainWindow.xaml.cs
@@ -45,8 +45,8 @@ public List Pro7Presentations
public MainWindow()
{
InitializeComponent();
- LogPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
- MainWindow_Window.Title = MainWindow_Window.Title + " (" + Assembly.GetExecutingAssembly().GetName().Version + ")";
+ LogPath = Path.GetDirectoryName(typeof(App).Assembly.Location);
+ MainWindow_Window.Title = $"{MainWindow_Window.Title} ({typeof(App).Assembly.GetName().Version})";
AddLog(MainWindow_Window.Title + " started");
// Quick and rough way to build combobox list of all keys/scale without proper data binding/MVVM....
@@ -127,7 +127,7 @@ public MainWindow()
private void AddLog(string logMessage)
{
if (!Directory.Exists(LogPath))
- LogPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
+ LogPath = Path.GetDirectoryName(typeof(App).Assembly.Location);
string logFileName = LogPath + @"\Pro7ChordEditor.log";
try
diff --git a/Pro7ChordEditor/Pro7ChordEditor.csproj b/Pro7ChordEditor/Pro7ChordEditor.csproj
index a7e042a..91a96fe 100644
--- a/Pro7ChordEditor/Pro7ChordEditor.csproj
+++ b/Pro7ChordEditor/Pro7ChordEditor.csproj
@@ -12,8 +12,6 @@
false
false
true
- 0
- 1.0.0.%2a
false
false
true
@@ -21,18 +19,6 @@
true
true
-
-
- False
- Microsoft .NET Framework 4.7.2 %28x86 and x64%29
- true
-
-
- False
- .NET Framework 3.5 SP1
- false
-
-
diff --git a/Pro7ChordEditor/Properties/PublishProfiles/FrameworkDependent.pubxml b/Pro7ChordEditor/Properties/PublishProfiles/FrameworkDependent.pubxml
new file mode 100644
index 0000000..2ec0f99
--- /dev/null
+++ b/Pro7ChordEditor/Properties/PublishProfiles/FrameworkDependent.pubxml
@@ -0,0 +1,18 @@
+
+
+
+ Release
+ Any CPU
+ bin\Release\net8.0-windows\_publish\FrameworkDependent\
+ bin\Release\net8.0-windows\_publish\FrameworkDependent\
+ FileSystem
+ <_TargetId>Folder
+ net8.0-windows
+ win-x64
+ false
+ false
+ false
+ en
+ en
+
+
\ No newline at end of file
diff --git a/Pro7ChordEditor/Properties/PublishProfiles/SelfContained.pubxml b/Pro7ChordEditor/Properties/PublishProfiles/SelfContained.pubxml
new file mode 100644
index 0000000..c0aa835
--- /dev/null
+++ b/Pro7ChordEditor/Properties/PublishProfiles/SelfContained.pubxml
@@ -0,0 +1,18 @@
+
+
+
+ Release
+ Any CPU
+ bin\Release\net8.0-windows\_publish\SelfContained\
+ bin\Release\net8.0-windows\_publish\SelfContained\
+ FileSystem
+ <_TargetId>Folder
+ net8.0-windows
+ win-x64
+ true
+ false
+ false
+ en
+ en
+
+
\ No newline at end of file
diff --git a/publish.py b/publish.py
new file mode 100644
index 0000000..89fdb7b
--- /dev/null
+++ b/publish.py
@@ -0,0 +1,98 @@
+from os import chdir, system
+import re
+
+VERSION_RE = r'\d+(?:\.\d+){0,3}(?:-.+?)?'
+ASSEMBLYINFO_PATH = r'PRo7ChordEditor\AssemblyInfo.cs'
+PUBLISH_PATH = r'PRo7ChordEditor\bin\Release\net8.0-windows\_publish'
+
+def get_curr_ver() -> str | None:
+ try:
+ with open(ASSEMBLYINFO_PATH) as file:
+ data = file.read()
+ ver = re.search(fr'\[assembly: AssemblyVersion\("({VERSION_RE})"\)\]', data).group(1)
+ return ver
+ except FileNotFoundError:
+ print('\x1b[33;1mWARNING\x1b[0m: AssemblyInfo.cs not found')
+ return None
+ except Exception as e:
+ print(f'\x1b[33;1mWARNING\x1b[0m: Unable to read the current version from AssemblyInfo.cs:\n {e}')
+ return None
+
+def suggest_next_ver(curr_ver: str) -> str:
+ ver = curr_ver.split('-')[0].split('.')
+ suggestions = []
+ for i in range(len(ver)):
+ s = ver.copy()
+ s[i] = str(int(s[i]) + 1)
+ for j in range(i + 1, len(ver)):
+ s[j] = '0'
+ while len(s) < 3:
+ s.append('0')
+ if len(s) == 4 and s[3] == '0':
+ s.pop()
+ suggestions.append('.'.join(s))
+ suggestions.reverse()
+ return suggestions
+
+def main():
+ print('==== \x1b[32mPro7 Chord Editor publish tool\x1b[0m ====')
+ curr_ver = get_curr_ver()
+
+ if curr_ver:
+ print(f'Current version of the program is \x1b[4m{curr_ver}\x1b[0m')
+ suggestions = suggest_next_ver(curr_ver)
+ print('\x1b[2mSuggested new versions:\x1b[0m')
+ for s in suggestions:
+ print(f' \x1b[2m{s}\x1b[0m')
+
+ new_ver: str = input('New version: ')
+
+ if new_ver not in suggestions:
+ print('\x1b[33;1mWARNING\x1b[0m: Not a sequential version')
+ print('Do you want to continue? (y/N) ', end='')
+ c = input().strip().lower()
+ if c != 'y':
+ print('Aborted')
+ return
+
+ with open(ASSEMBLYINFO_PATH) as file:
+ data = file.read()
+ data = re.sub(fr'(\[assembly: AssemblyVersion\()"{VERSION_RE}"(\)\])', fr'\1"{new_ver}"\2', data)
+
+ with open(ASSEMBLYINFO_PATH, 'w') as file:
+ file.write(data)
+
+ print(f'Version updated to \x1b[4m{new_ver}\x1b[0m')
+
+ print('Are you sure you want to continue? (y/N) ', end='')
+ c = input().strip().lower()
+ if c != 'y':
+ print('Aborted')
+ return
+
+ print('==== \x1b[32mCommitting...\x1b[0m ====')
+
+ system(r'git add PRo7ChordEditor\AssemblyInfo.cs')
+ system(f'git commit -m "Version {new_ver}"')
+ system('git push')
+ system(f'git tag -a v{new_ver} -m "Version {new_ver}"')
+ system('git push --tags')
+
+ print('==== \x1b[32mPublishing...\x1b[0m ====')
+
+ system('dotnet clean')
+
+ system('dotnet publish -p:PublishProfile=FrameworkDependent')
+ system('dotnet publish -p:PublishProfile=SelfContained')
+
+ print('==== \x1b[32mCompressing...\x1b[0m ====')
+
+ chdir(fr'{PUBLISH_PATH}\FrameworkDependent')
+ system(fr'tar -acvf ..\PRo7ChordEditor-{new_ver}-FD.zip *')
+ chdir(fr'..\SelfContained')
+ system(fr'tar -acvf ..\PRo7ChordEditor-{new_ver}-SC.zip *')
+
+ print('==== \x1b[32mDone\x1b[0m ====')
+
+if __name__ == '__main__':
+ main()