Skip to content

Commit

Permalink
Changed the installer to check for updates by getting the "Image sort…
Browse files Browse the repository at this point in the history
….UI.exe" assembly version, instead of using an hard coded version.
  • Loading branch information
Luca Auer authored and Luca Auer committed May 31, 2018
1 parent 115ee3a commit 925da1b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Image sort.Update/Image sort.Update.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
Expand Down
16 changes: 11 additions & 5 deletions Image sort.Update/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Program
/// <param name="args"></param>
static void Main(string[] args)
{
#if (!DEBUG)
#if (!DEBUG || true)
// If the updater is already open once, don't open another instance/
// close this one right after start.
if (Process.GetProcessesByName("Image sort.Update").Count() > 1)
Expand All @@ -40,8 +40,11 @@ static void Main(string[] args)
// Serializes the UpdateRegistry from json
UpdateRegModel updateReg = JsonConvert.DeserializeObject<UpdateRegModel>(json);
if (updateReg != null)
{
Version version = System.Reflection.Assembly.LoadFile($"{AppDomain.CurrentDomain.BaseDirectory}\\Image sort.UI.exe")
.GetName().Version;
// if the version given is different, download and run the newest update
if (updateReg.version != Properties.Resources.version)
if (updateReg.version != $"{version.Major}.{version.Minor}.{version.Build}" /*Properties.Resources.version*/)
{
// If the process isn't elevated, ask if update
if (!IsElevated)
Expand All @@ -53,9 +56,11 @@ static void Main(string[] args)
{
// Elevate process
ProcessStartInfo info = new ProcessStartInfo(AppDomain.CurrentDomain.BaseDirectory +
@"Image sort.Update.exe");
info.UseShellExecute = true;
info.Verb = "runas";
@"Image sort.Update.exe")
{
UseShellExecute = true,
Verb = "runas"
};
Process.Start(info);
}
}
Expand All @@ -71,6 +76,7 @@ static void Main(string[] args)
DownloadAndRunInstaller(url);
}
}
}
}
#endif
}
Expand Down

0 comments on commit 925da1b

Please sign in to comment.