diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index ecfe0c7e..0b96632a 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -45,7 +45,7 @@ jobs:
run: "msbuild PCK_Studio.sln -p:Configuration=Release"
- name: Package binary
- run: Compress-Archive -Path ${{ github.workspace }}\PCK-Studio\bin\Release\ -Destination ${{ env.RELEASE_NAME }}.zip
+ run: Compress-Archive -Path "${{ github.workspace }}\PCK-Studio\bin\Release\*" -Destination ${{ env.RELEASE_NAME }}.zip
- name: Release
uses: softprops/action-gh-release@v2
diff --git a/PCK-Studio-Updater/API/GithubUpdateDownloader.cs b/PCK-Studio-Updater/API/GithubUpdateDownloader.cs
index b89c3897..663da45e 100644
--- a/PCK-Studio-Updater/API/GithubUpdateDownloader.cs
+++ b/PCK-Studio-Updater/API/GithubUpdateDownloader.cs
@@ -47,7 +47,7 @@ namespace PCKStudio_Updater
{
Debug.WriteLine("Release Product ver.: " + latestReleaseVersion);
Debug.WriteLine("Current Product ver.: " + productVersion);
- return latestReleaseVersion.CompareTo(productVersion) > 0;
+ return latestReleaseVersion.CompareTo(productVersion) >= 0;
}
public bool IsUpdateAvailable(string productVersion)
@@ -101,10 +101,9 @@ namespace PCKStudio_Updater
private void EmptyDirectory(DirectoryInfo directory)
{
- string appname = Assembly.GetExecutingAssembly().GetName().Name;
foreach (FileInfo file in directory.GetFiles())
{
- if (Path.GetFileNameWithoutExtension(file.Name) != appname && file.Name != "update.zip")
+ if (Path.GetFileNameWithoutExtension(file.Name) != _updateParams.TargetExecutableName && file.Name != "update.zip")
file.Delete();
}
foreach (DirectoryInfo subDirectory in directory.GetDirectories())
@@ -118,7 +117,7 @@ namespace PCKStudio_Updater
if (latestFetchedRelease.Assets?.Count > 0)
{
var asset = latestFetchedRelease.Assets[0];
- string zipFilePath = Path.Combine(directory.FullName, "update.zip");
+ string zipFilePath = Path.Combine(directory.FullName, asset.Name);
using(var zipFileStream = File.OpenWrite(zipFilePath))
{
DownloadAsset(asset, zipFileStream);
@@ -126,7 +125,6 @@ namespace PCKStudio_Updater
Debug.WriteLine("Download Complete", category: nameof(GithubUpdateDownloader));
EmptyDirectory(directory);
UnpackZip(zipFilePath);
- File.Delete(zipFilePath);
downloadDirectory = directory;
}
}
diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs
index b376b921..75a68d6c 100644
--- a/PCK-Studio/MainForm.cs
+++ b/PCK-Studio/MainForm.cs
@@ -2480,12 +2480,7 @@ namespace PckStudio
private void checkForUpdatesToolStripMenuItem_Click(object sender, EventArgs e)
{
- if (Program.Updater.IsUpdateAvailable(Application.ProductVersion))
- {
- Program.UpdateToLatest("Would you like to download it?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, DialogResult.Yes);
- return;
- }
- MessageBox.Show(this, "Already up to date.", "No update available");
+ Program.UpdateToLatest();
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
diff --git a/PCK-Studio/PckStudio.csproj b/PCK-Studio/PckStudio.csproj
index 3e9d2105..c82f17d4 100644
--- a/PCK-Studio/PckStudio.csproj
+++ b/PCK-Studio/PckStudio.csproj
@@ -679,6 +679,9 @@
1.0.5
+
+ 1.9.1
+
5.8.0-alpha0098
compile; runtime; build; native; contentfiles; analyzers; buildtransitive
@@ -716,10 +719,6 @@
-
- {5B223556-15B9-41DA-AA0B-5E7F45E743BF}
- PCK-Studio-Updater
-
{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB}
OMI Filetype Library
diff --git a/PCK-Studio/Program.cs b/PCK-Studio/Program.cs
index 393faaf9..e26bddc9 100644
--- a/PCK-Studio/Program.cs
+++ b/PCK-Studio/Program.cs
@@ -6,8 +6,9 @@ using System.Windows.Forms;
using PckStudio.Internal.Misc;
using PckStudio.Internal;
using PckStudio.Properties;
-using PCKStudio_Updater;
using PckStudio.Internal.App;
+using AutoUpdaterDotNET;
+using Newtonsoft.Json;
namespace PckStudio
@@ -15,22 +16,13 @@ namespace PckStudio
static class Program
{
internal static readonly Uri ProjectUrl = new Uri("https://github.com/PhoenixARC/-PCK-Studio");
+ internal static readonly Uri RawProjectUrl = new Uri("https://raw.githubusercontent.com/PhoenixARC/-PCK-Studio");
internal static readonly string BaseAPIUrl = "http://api.pckstudio.xyz/api/pck";
internal static readonly string BackUpAPIUrl = "https://raw.githubusercontent.com/PhoenixARC/pckstudio.tk/main/studio/PCK/api/";
internal static readonly string AppData = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), Application.ProductName);
internal static readonly string AppDataCache = Path.Combine(AppData, "cache");
- private static readonly GithubParams UpdateParams = new GithubParams(
- Path.GetDirectoryName(ProjectUrl.AbsolutePath).Replace("\\", ""),
- Path.GetFileName(ProjectUrl.AbsolutePath),
- Application.ProductName,
- Settings.Default.UsePrerelease,
- new Regex("(\\*|\\d+(\\.\\d+){0,3}(\\.\\*)?)")
- );
- internal static readonly IUpdateDownloader Updater = new GithubUpdateDownloader(UpdateParams);
-
-
internal static MainForm MainInstance { get; private set; }
///
@@ -39,9 +31,23 @@ namespace PckStudio
[STAThread]
static void Main(string[] args)
{
+ AutoUpdater.SetOwner(MainInstance);
+ //AutoUpdater.ClearAppDirectory = true;
+#if DEBUG
+ AutoUpdater.ReportErrors = true;
+#endif
+ AutoUpdater.DownloadPath = Application.StartupPath;
+ AutoUpdater.ExecutablePath = "./PCK-Studio.exe";
+ AutoUpdater.TopMost = true;
+
+ string jsonPath = Path.Combine(Environment.CurrentDirectory, "updates.json");
+ AutoUpdater.PersistenceProvider = new JsonFilePersistenceProvider(jsonPath);
+ AutoUpdater.ParseUpdateInfoEvent += AutoUpdaterOnParseUpdateInfoEvent;
+ AutoUpdater.Icon = Resources.ProjectLogo.ToBitmap();
+
if (Settings.Default.AutoUpdate)
{
- UpdateToLatest("Click Ok to continue.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, DialogResult.OK);
+ UpdateToLatest();
}
ApplicationScope.Initialize();
@@ -51,24 +57,48 @@ namespace PckStudio
if (args.Length > 0 && File.Exists(args[0]) && args[0].EndsWith(".pck"))
MainInstance.InitPckFromFile(args[0]);
Application.ApplicationExit += (sender, e) => { RPC.Deinitialize(); };
+ MainInstance.FocusMe();
Application.Run(MainInstance);
}
- [Conditional("NDEBUG")]
- internal static void UpdateToLatest(string message, MessageBoxButtons buttons, MessageBoxIcon icon, DialogResult dialogResult)
+
+ internal static void UpdateToLatest()
{
- bool updateAvailable = Updater.IsUpdateAvailable(Application.ProductVersion);
- if (updateAvailable && MessageBox.Show(
- MainInstance ?? null,
- "New update available.\n" +
- message,
- "Update Available",
- buttons, icon, MessageBoxDefaultButton.Button1) == dialogResult)
- {
- Updater.DownloadTo(new DirectoryInfo(Application.StartupPath));
- Updater.Launch();
- Application.Exit();
- }
+#if NDEBUG
+ string url = $"{RawProjectUrl}/main/Version.json";
+ AutoUpdater.Start(url);
+#endif
}
+
+ class UpdateInfo
+ {
+ [JsonProperty("version")]
+ public string Version { get; set; }
+
+ [JsonProperty("url")]
+ public string Url { get; set; }
+
+ [JsonProperty("changelog")]
+ public string Changelog { get; set; }
+
+ [JsonProperty("mandatory")]
+ public bool Mandatory { get; set; }
+ }
+
+ private static void AutoUpdaterOnParseUpdateInfoEvent(ParseUpdateInfoEventArgs args)
+ {
+ UpdateInfo json = JsonConvert.DeserializeObject(args.RemoteData);
+ args.UpdateInfo = new UpdateInfoEventArgs
+ {
+ CurrentVersion = json.Version,
+ DownloadURL = json.Url,
+ ChangelogURL = json.Changelog,
+ Mandatory = new Mandatory()
+ {
+ Value = json.Mandatory,
+ }
+ };
+ }
+
}
}
\ No newline at end of file
diff --git a/PCK_Studio.sln b/PCK_Studio.sln
index 772bd2c5..8062268c 100644
--- a/PCK_Studio.sln
+++ b/PCK_Studio.sln
@@ -11,8 +11,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OMI Filetype Library", "Ven
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpMss32", "Vendor\SharpMss32\SharpMss32\SharpMss32.csproj", "{E8D0B671-3AB1-48B6-A767-58DF67BD5D11}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PCK-Studio-Updater", "PCK-Studio-Updater\PCK-Studio-Updater.csproj", "{5B223556-15B9-41DA-AA0B-5E7F45E743BF}"
-EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Beta|Any CPU = Beta|Any CPU
@@ -80,24 +78,6 @@ Global
{E8D0B671-3AB1-48B6-A767-58DF67BD5D11}.Release|x64.Build.0 = Release|Any CPU
{E8D0B671-3AB1-48B6-A767-58DF67BD5D11}.Release|x86.ActiveCfg = Release|Any CPU
{E8D0B671-3AB1-48B6-A767-58DF67BD5D11}.Release|x86.Build.0 = Release|Any CPU
- {5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Beta|Any CPU.ActiveCfg = Debug|Any CPU
- {5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Beta|Any CPU.Build.0 = Debug|Any CPU
- {5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Beta|x64.ActiveCfg = Debug|Any CPU
- {5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Beta|x64.Build.0 = Debug|Any CPU
- {5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Beta|x86.ActiveCfg = Debug|Any CPU
- {5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Beta|x86.Build.0 = Debug|Any CPU
- {5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Debug|x64.ActiveCfg = Debug|Any CPU
- {5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Debug|x64.Build.0 = Debug|Any CPU
- {5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Debug|x86.ActiveCfg = Debug|Any CPU
- {5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Debug|x86.Build.0 = Debug|Any CPU
- {5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Release|Any CPU.Build.0 = Release|Any CPU
- {5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Release|x64.ActiveCfg = Release|Any CPU
- {5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Release|x64.Build.0 = Release|Any CPU
- {5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Release|x86.ActiveCfg = Release|Any CPU
- {5B223556-15B9-41DA-AA0B-5E7F45E743BF}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Version.json b/Version.json
new file mode 100644
index 00000000..a2f213fc
--- /dev/null
+++ b/Version.json
@@ -0,0 +1,6 @@
+{
+ "version": "7.0.0.0",
+ "url": "https://github.com/PhoenixARC/-PCK-Studio/releases/download/v7.0.0.0/PCK-Studio.zip",
+ "changelog": "https://raw.githubusercontent.com/PhoenixARC/-PCK-Studio/main/CHANGELOG.md",
+ "mandatory": false
+}
\ No newline at end of file