Fix for automatic update. Versionhelper has loaded the application dll :/

This commit is contained in:
Serraniel 2017-12-16 16:04:01 +01:00
parent 219f4601cd
commit 3bbe5e72c5
3 changed files with 18 additions and 6 deletions

View file

@ -35,7 +35,7 @@ namespace Discord_Media_Loader
downloadManager.ShowDialog();
var tmpFolder = Path.GetTempFileName();
tmpFolder = Path.Combine(Path.GetFullPath(tmpFolder).Replace(Path.GetFileName(tmpFolder),""), Path.GetFileNameWithoutExtension(tmpFolder));
tmpFolder = Path.Combine(Path.GetFullPath(tmpFolder).Replace(Path.GetFileName(tmpFolder), ""), Path.GetFileNameWithoutExtension(tmpFolder));
var di = Directory.CreateDirectory(tmpFolder);
@ -52,6 +52,7 @@ namespace Discord_Media_Loader
}
File.Delete(tmpFile);
DialogResult = DialogResult.Cancel;
}
}
finally
@ -59,7 +60,7 @@ namespace Discord_Media_Loader
UseWaitCursor = false;
}
Close();
DialogResult = DialogResult.OK;
}
}
}

View file

@ -13,7 +13,8 @@ namespace Discord_Media_Loader.Helper
internal class VersionHelper
{
internal static Version CurrentVersion => Assembly.GetExecutingAssembly().GetName().Version;
internal static Version AppVersion => typeof(Core).Assembly.GetName().Version;
internal static Version AppVersion => AssemblyName.GetAssemblyName("Discord Media Loader.Application.dll").Version;
internal static async Task<Version> GetReleaseVersion()
{
@ -35,7 +36,7 @@ namespace Discord_Media_Loader.Helper
{
var github = new GitHubClient(new ProductHeaderValue("DiscordMediaLoader"));
var releaseVersion = (from release in (await github.Repository.Release.GetAll("Serraniel", "DiscordMediaLoader")) where release.TagName == $"v{version.Major}.{version.Minor}.{version.Build}.{version.Revision}" select release).First();
return releaseVersion.Assets.FirstOrDefault()?.BrowserDownloadUrl;
}
}

View file

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime;
using System.Threading.Tasks;
using System.Windows.Forms;
@ -20,10 +21,19 @@ namespace Discord_Media_Loader
Application.SetCompatibleTextRenderingDefault(false);
var splashScreen = new FrmSplash();
splashScreen.ShowDialog();
if (splashScreen.ShowDialog() == DialogResult.OK)
{
DoLaunch(paramStrings);
}
else
{
Application.Restart();
}
}
private static void DoLaunch(string[] paramStrings)
{
AsyncContext.Run(() => Core.Run(paramStrings));
Console.WriteLine("Ende");
}
}
}