Skip to content

Commit

Permalink
Release 1.0.9 Fix automatic updater broken by the Switch to .Net5 ;(
Browse files Browse the repository at this point in the history
  • Loading branch information
popcatalin81 committed Sep 8, 2021
1 parent 17b63cf commit 75e3ea6
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 11 deletions.
13 changes: 11 additions & 2 deletions QBTracker.AutomaticUpdader/QBTracker.AutomaticUpdader.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>exe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<AssemblyVersion>0.0.5.0</AssemblyVersion>
<AssemblyVersion>0.0.6.0</AssemblyVersion>
<Authors>Catalin Pop</Authors>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
<AssemblyName>QBTrackerAutomaticUpdader</AssemblyName>
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand All @@ -28,4 +31,10 @@
<Folder Include="Properties\" />
</ItemGroup>

<ItemGroup>
<None Update="QBTrackerAutomaticU[dater.runtimeconfig.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"runtimeOptions": {
"tfm": "net5.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "5.0.0"
}
}
}
16 changes: 16 additions & 0 deletions QBTracker.AutomaticUpdader/UpdaterService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,21 @@ public async Task<bool> CheckForUpdate(bool force = false)
return false;
}

public void ExtractUpdater(Assembly assembly)
{
try
{
var names = assembly.GetManifestResourceNames();
using var stream = assembly.GetManifestResourceStream("QBTracker.Embeded.QBTrackerAutomaticUpdader.exe");
using var fs = File.Create(Path.Combine(TempAssembliesFolder, "QBTracker.AutomaticUpdader.exe"));
stream.CopyTo(fs);
}
catch (Exception ex)
{
LogMessage(ex.Message);
}
}

public void LogMessage(string message)
{
liteRepository.Insert(new LogEntry
Expand Down Expand Up @@ -222,6 +237,7 @@ public async Task<bool> DownloadUpdate(Action<float> progressCallback = null)

public void StartUpdater()
{
this.ExtractUpdater(Assembly.GetCallingAssembly());
var p = Process.Start(new ProcessStartInfo(Path.Combine(TempAssembliesFolder, "QBTracker.AutomaticUpdader.exe"), "--updateAndRestart")
{
UseShellExecute = false,
Expand Down
10 changes: 8 additions & 2 deletions QBTracker/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
using System.Linq;
using System.Threading;
using System.Windows;

using MaterialDesignThemes.Wpf;

using QBTracker.DataAccess;

namespace QBTracker
Expand All @@ -12,11 +14,13 @@ namespace QBTracker
/// </summary>
public partial class App : Application
{
#if !DEBUG
private Mutex mutex;
#endif

protected override void OnStartup(StartupEventArgs e)
{
#if !DEBUG
#if !DEBUG
const string mutexName = @"Global\QBTracker";

mutex = new Mutex(true, mutexName, out var createdNew);
Expand All @@ -34,13 +38,15 @@ protected override void OnStartup(StartupEventArgs e)
bundle.SecondaryColor = settings.SecondaryColor.Value;
}
}
#endif
#endif
base.OnStartup(e);
}

protected override void OnExit(ExitEventArgs e)
{
#if !DEBUG
mutex.ReleaseMutex();
#endif
}
}
}
4 changes: 2 additions & 2 deletions QBTracker/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.8.0")]
[assembly: AssemblyFileVersion("1.0.8.0")]
[assembly: AssemblyVersion("1.0.9.0")]
[assembly: AssemblyFileVersion("1.0.9.0")]
15 changes: 10 additions & 5 deletions QBTracker/QBTracker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
<ValidateExecutableReferencesMatchSelfContained>false</ValidateExecutableReferencesMatchSelfContained>
<ValidateExecutableReferencesMatchSelfContained>true</ValidateExecutableReferencesMatchSelfContained>
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
</PropertyGroup>

<ItemGroup>
<None Remove="Images\pngfuel.ico" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="EPPlus" Version="4.5.3.3" />
<PackageReference Include="Hardcodet.NotifyIcon.Wpf.NetCore" Version="1.0.18" />
Expand Down Expand Up @@ -52,4 +49,12 @@
</Page>
</ItemGroup>

<ItemGroup>
<Folder Include="Embeded\" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="..\QBTracker.AutomaticUpdader\bin\Release\net5.0-windows\win-x64\publish\QBTrackerAutomaticUpdader.exe" Link="Embeded\QBTrackerAutomaticUpdader.exe" />
</ItemGroup>

</Project>

0 comments on commit 75e3ea6

Please sign in to comment.