Skip to content

Commit

Permalink
nsis installer
Browse files Browse the repository at this point in the history
  • Loading branch information
stakira committed Jun 6, 2023
1 parent 692b7dc commit 08d7693
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ OpenUtau.Test/Usts/*

.DS_Store
*.dmg
*.exe
appcast.*.xml
*.tar.gz
.vscode/
12 changes: 10 additions & 2 deletions OpenUtau.Core/Util/PathManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ public PathManager() {
CachePath = Path.Combine(cacheHome, "OpenUtau");
HomePathIsAscii = true;
} else {
DataPath = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
string exePath = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
IsInstalled = File.Exists(Path.Combine(exePath, "installed.txt"));
if (!IsInstalled) {
DataPath = exePath;
} else {
string dataHome = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
DataPath = Path.Combine(dataHome, "OpenUtau");
}
CachePath = Path.Combine(DataPath, "Cache");
HomePathIsAscii = true;
var etor = StringInfo.GetTextElementEnumerator(DataPath);
Expand All @@ -58,6 +65,7 @@ public PathManager() {
public string DataPath { get; private set; }
public string CachePath { get; private set; }
public bool HomePathIsAscii { get; private set; }
public bool IsInstalled { get; private set; }
public string SingersPathOld => Path.Combine(DataPath, "Content", "Singers");
public string SingersPath => Path.Combine(DataPath, "Singers");
public string AdditionalSingersPath => Preferences.Default.AdditionalSingerPath;
Expand Down Expand Up @@ -94,7 +102,7 @@ public string GetExportPath(string exportPath, UTrack track) {
Directory.CreateDirectory(dir);
var filename = Path.GetFileNameWithoutExtension(exportPath);
var trackName = invalid.Replace(track.TrackName, "_");
if(DocManager.Inst.Project.tracks.Count(t => t.TrackName == track.TrackName) > 1) {
if (DocManager.Inst.Project.tracks.Count(t => t.TrackName == track.TrackName) > 1) {
trackName += $"_{track.TrackNo:D2}";
}
return Path.Combine(dir, $"{filename}_{trackName}.wav");
Expand Down
108 changes: 108 additions & 0 deletions OpenUtau.nsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
; Script generated by the HM NIS Edit Script Wizard.

; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "OpenUtau"
!define PRODUCT_PUBLISHER "stakira"
!define PRODUCT_WEB_SITE "https://www.openutau.com"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"

; MUI 1.67 compatible ------
!include "MUI.nsh"

; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"

; Language Selection Dialog Settings
!define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"

; Welcome page
!insertmacro MUI_PAGE_WELCOME
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!define MUI_FINISHPAGE_RUN "$INSTDIR\OpenUtau.exe"
!insertmacro MUI_PAGE_FINISH

; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES

; Language files
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "German"
!insertmacro MUI_LANGUAGE "Japanese"
!insertmacro MUI_LANGUAGE "Korean"
!insertmacro MUI_LANGUAGE "Russian"
!insertmacro MUI_LANGUAGE "SimpChinese"

; MUI end ------

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "OpenUtau-win-x64.exe"
InstallDir "$PROGRAMFILES64\OpenUtau"
ShowInstDetails show
ShowUnInstDetails show

Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd

Section "MainSection" SEC01
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
File "bin\win-x64\*"
SectionEnd

Section -AdditionalIcons
WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
CreateDirectory "$SMPROGRAMS\OpenUtau"
CreateShortCut "$SMPROGRAMS\OpenUtau\OpenUtau.lnk" "$INSTDIR\OpenUtau.exe"
CreateShortCut "$SMPROGRAMS\OpenUtau\Uninstall.lnk" "$INSTDIR\uninst.exe"
SectionEnd

Section -Post
;leave a mark that the program was installed
FileOpen $9 "$INSTDIR\installed.txt" w
FileWrite $9 "yes"
FileClose $9

WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd


Function un.onUninstSuccess
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
FunctionEnd

Function un.onInit
!insertmacro MUI_UNGETLANGUAGE
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
Abort
FunctionEnd

Section Uninstall
Delete "$INSTDIR\${PRODUCT_NAME}.url"
Delete "$INSTDIR\uninst.exe"
Delete "$INSTDIR\*"

Delete "$SMPROGRAMS\OpenUtau\Uninstall.lnk"

RMDir "$SMPROGRAMS\OpenUtau"
RMDir "$INSTDIR"

DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
SetAutoClose true
SectionEnd
1 change: 0 additions & 1 deletion OpenUtau/OpenUtau.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
<TargetFramework>net6.0-windows</TargetFramework>
<PublishSingleFile>true</PublishSingleFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT' ">
<TargetFramework>net6.0</TargetFramework>
Expand Down
3 changes: 2 additions & 1 deletion OpenUtau/ViewModels/UpdaterViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ public UpdaterViewModel() {
}

static GithubReleaseAsset? SelectAppcast(GithubRelease release) {
string suffix = PathManager.Inst.IsInstalled ? "-installer" : "";
return release.assets
.Where(a => a.name == $"appcast.{OS.GetUpdaterRid()}.xml")
.Where(a => a.name == $"appcast.{OS.GetUpdaterRid()}{suffix}.xml")
.FirstOrDefault();
}

Expand Down
3 changes: 3 additions & 0 deletions appveyor.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ def write_appcast(appcast_os, appcast_rid, appcast_file):
os.system("copy /y OpenUtau.Plugin.Builtin\\bin\\Release\\netstandard2.1\\OpenUtau.Plugin.Builtin.dll bin\\win-x64")
write_appcast("windows", "win-x64", "OpenUtau-win-x64.zip")

os.system("makensis -DPRODUCT_VERSION=%s OpenUtau.nsi" % (appcast_ver))
write_appcast("windows", "win-x64-installer", "OpenUtau-win-x64.exe")

elif sys.platform == 'darwin':
os.system("rm *.dmg")
os.system("rm *.xml")
Expand Down
2 changes: 2 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ artifacts:
- path: bin\win-x64
name: OpenUtau-win-x64
type: zip
- path: OpenUtau-win-x64.exe
- path: OpenUtau-osx-x64.dmg
- path: OpenUtau-linux-x64.tar.gz
- path: appcast.win-x86.xml
- path: appcast.win-x64.xml
- path: appcast.win-x64-installer.xml
- path: appcast.linux-x64.xml
- path: appcast.osx-x64.xml
- path: changelog.txt
Expand Down

0 comments on commit 08d7693

Please sign in to comment.