Skip to content

Commit 08d7693

Browse files
committed
nsis installer
1 parent 692b7dc commit 08d7693

File tree

7 files changed

+126
-4
lines changed

7 files changed

+126
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ OpenUtau.Test/Usts/*
335335

336336
.DS_Store
337337
*.dmg
338+
*.exe
338339
appcast.*.xml
339340
*.tar.gz
340341
.vscode/

OpenUtau.Core/Util/PathManager.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,14 @@ public PathManager() {
4040
CachePath = Path.Combine(cacheHome, "OpenUtau");
4141
HomePathIsAscii = true;
4242
} else {
43-
DataPath = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
43+
string exePath = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
44+
IsInstalled = File.Exists(Path.Combine(exePath, "installed.txt"));
45+
if (!IsInstalled) {
46+
DataPath = exePath;
47+
} else {
48+
string dataHome = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
49+
DataPath = Path.Combine(dataHome, "OpenUtau");
50+
}
4451
CachePath = Path.Combine(DataPath, "Cache");
4552
HomePathIsAscii = true;
4653
var etor = StringInfo.GetTextElementEnumerator(DataPath);
@@ -58,6 +65,7 @@ public PathManager() {
5865
public string DataPath { get; private set; }
5966
public string CachePath { get; private set; }
6067
public bool HomePathIsAscii { get; private set; }
68+
public bool IsInstalled { get; private set; }
6169
public string SingersPathOld => Path.Combine(DataPath, "Content", "Singers");
6270
public string SingersPath => Path.Combine(DataPath, "Singers");
6371
public string AdditionalSingersPath => Preferences.Default.AdditionalSingerPath;
@@ -94,7 +102,7 @@ public string GetExportPath(string exportPath, UTrack track) {
94102
Directory.CreateDirectory(dir);
95103
var filename = Path.GetFileNameWithoutExtension(exportPath);
96104
var trackName = invalid.Replace(track.TrackName, "_");
97-
if(DocManager.Inst.Project.tracks.Count(t => t.TrackName == track.TrackName) > 1) {
105+
if (DocManager.Inst.Project.tracks.Count(t => t.TrackName == track.TrackName) > 1) {
98106
trackName += $"_{track.TrackNo:D2}";
99107
}
100108
return Path.Combine(dir, $"{filename}_{trackName}.wav");

OpenUtau.nsi

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
; Script generated by the HM NIS Edit Script Wizard.
2+
3+
; HM NIS Edit Wizard helper defines
4+
!define PRODUCT_NAME "OpenUtau"
5+
!define PRODUCT_PUBLISHER "stakira"
6+
!define PRODUCT_WEB_SITE "https://www.openutau.com"
7+
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
8+
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
9+
10+
; MUI 1.67 compatible ------
11+
!include "MUI.nsh"
12+
13+
; MUI Settings
14+
!define MUI_ABORTWARNING
15+
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
16+
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
17+
18+
; Language Selection Dialog Settings
19+
!define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
20+
!define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
21+
!define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"
22+
23+
; Welcome page
24+
!insertmacro MUI_PAGE_WELCOME
25+
; Directory page
26+
!insertmacro MUI_PAGE_DIRECTORY
27+
; Instfiles page
28+
!insertmacro MUI_PAGE_INSTFILES
29+
; Finish page
30+
!define MUI_FINISHPAGE_RUN "$INSTDIR\OpenUtau.exe"
31+
!insertmacro MUI_PAGE_FINISH
32+
33+
; Uninstaller pages
34+
!insertmacro MUI_UNPAGE_INSTFILES
35+
36+
; Language files
37+
!insertmacro MUI_LANGUAGE "English"
38+
!insertmacro MUI_LANGUAGE "French"
39+
!insertmacro MUI_LANGUAGE "German"
40+
!insertmacro MUI_LANGUAGE "Japanese"
41+
!insertmacro MUI_LANGUAGE "Korean"
42+
!insertmacro MUI_LANGUAGE "Russian"
43+
!insertmacro MUI_LANGUAGE "SimpChinese"
44+
45+
; MUI end ------
46+
47+
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
48+
OutFile "OpenUtau-win-x64.exe"
49+
InstallDir "$PROGRAMFILES64\OpenUtau"
50+
ShowInstDetails show
51+
ShowUnInstDetails show
52+
53+
Function .onInit
54+
!insertmacro MUI_LANGDLL_DISPLAY
55+
FunctionEnd
56+
57+
Section "MainSection" SEC01
58+
SetOutPath "$INSTDIR"
59+
SetOverwrite ifnewer
60+
File "bin\win-x64\*"
61+
SectionEnd
62+
63+
Section -AdditionalIcons
64+
WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
65+
CreateDirectory "$SMPROGRAMS\OpenUtau"
66+
CreateShortCut "$SMPROGRAMS\OpenUtau\OpenUtau.lnk" "$INSTDIR\OpenUtau.exe"
67+
CreateShortCut "$SMPROGRAMS\OpenUtau\Uninstall.lnk" "$INSTDIR\uninst.exe"
68+
SectionEnd
69+
70+
Section -Post
71+
;leave a mark that the program was installed
72+
FileOpen $9 "$INSTDIR\installed.txt" w
73+
FileWrite $9 "yes"
74+
FileClose $9
75+
76+
WriteUninstaller "$INSTDIR\uninst.exe"
77+
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
78+
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
79+
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
80+
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
81+
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
82+
SectionEnd
83+
84+
85+
Function un.onUninstSuccess
86+
HideWindow
87+
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
88+
FunctionEnd
89+
90+
Function un.onInit
91+
!insertmacro MUI_UNGETLANGUAGE
92+
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
93+
Abort
94+
FunctionEnd
95+
96+
Section Uninstall
97+
Delete "$INSTDIR\${PRODUCT_NAME}.url"
98+
Delete "$INSTDIR\uninst.exe"
99+
Delete "$INSTDIR\*"
100+
101+
Delete "$SMPROGRAMS\OpenUtau\Uninstall.lnk"
102+
103+
RMDir "$SMPROGRAMS\OpenUtau"
104+
RMDir "$INSTDIR"
105+
106+
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
107+
SetAutoClose true
108+
SectionEnd

OpenUtau/OpenUtau.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
33
<TargetFramework>net6.0-windows</TargetFramework>
4-
<PublishSingleFile>true</PublishSingleFile>
54
</PropertyGroup>
65
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT' ">
76
<TargetFramework>net6.0</TargetFramework>

OpenUtau/ViewModels/UpdaterViewModel.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@ public UpdaterViewModel() {
9696
}
9797

9898
static GithubReleaseAsset? SelectAppcast(GithubRelease release) {
99+
string suffix = PathManager.Inst.IsInstalled ? "-installer" : "";
99100
return release.assets
100-
.Where(a => a.name == $"appcast.{OS.GetUpdaterRid()}.xml")
101+
.Where(a => a.name == $"appcast.{OS.GetUpdaterRid()}{suffix}.xml")
101102
.FirstOrDefault();
102103
}
103104

appveyor.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ def write_appcast(appcast_os, appcast_rid, appcast_file):
4949
os.system("copy /y OpenUtau.Plugin.Builtin\\bin\\Release\\netstandard2.1\\OpenUtau.Plugin.Builtin.dll bin\\win-x64")
5050
write_appcast("windows", "win-x64", "OpenUtau-win-x64.zip")
5151

52+
os.system("makensis -DPRODUCT_VERSION=%s OpenUtau.nsi" % (appcast_ver))
53+
write_appcast("windows", "win-x64-installer", "OpenUtau-win-x64.exe")
54+
5255
elif sys.platform == 'darwin':
5356
os.system("rm *.dmg")
5457
os.system("rm *.xml")

appveyor.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ artifacts:
3737
- path: bin\win-x64
3838
name: OpenUtau-win-x64
3939
type: zip
40+
- path: OpenUtau-win-x64.exe
4041
- path: OpenUtau-osx-x64.dmg
4142
- path: OpenUtau-linux-x64.tar.gz
4243
- path: appcast.win-x86.xml
4344
- path: appcast.win-x64.xml
45+
- path: appcast.win-x64-installer.xml
4446
- path: appcast.linux-x64.xml
4547
- path: appcast.osx-x64.xml
4648
- path: changelog.txt

0 commit comments

Comments
 (0)