Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.

Commit 254f39f

Browse files
committed
switched installing/updating to squirrel
1 parent e90b02d commit 254f39f

File tree

11 files changed

+104
-108
lines changed

11 files changed

+104
-108
lines changed

adrilight.benchmarks/packages.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<package id="Microsoft.CodeAnalysis.Analyzers" version="1.1.0" targetFramework="net471" />
77
<package id="Microsoft.CodeAnalysis.Common" version="2.0.0" targetFramework="net471" />
88
<package id="Microsoft.CodeAnalysis.CSharp" version="2.0.0" targetFramework="net471" />
9+
<package id="NuGet.CommandLine" version="4.6.2" targetFramework="net471" developmentDependency="true" />
910
<package id="System.AppContext" version="4.3.0" targetFramework="net471" />
1011
<package id="System.Collections" version="4.3.0" targetFramework="net471" />
1112
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net471" />

adrilight/App.config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
<assemblyIdentity name="Ninject" publicKeyToken="c7192dc5380945e7" culture="neutral" />
2323
<bindingRedirect oldVersion="0.0.0.0-3.3.4.0" newVersion="3.3.4.0" />
2424
</dependentAssembly>
25+
<dependentAssembly>
26+
<assemblyIdentity name="Microsoft.ApplicationInsights" publicKeyToken="31bf3856ad364e35" culture="neutral" />
27+
<bindingRedirect oldVersion="0.0.0.0-2.5.1.0" newVersion="2.5.1.0" />
28+
</dependentAssembly>
2529
</assemblyBinding>
2630
</runtime>
2731
<nlog>

adrilight/App.xaml.cs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ private void SetupNotifyIcon()
190190

191191
var notifyIcon = new System.Windows.Forms.NotifyIcon()
192192
{
193-
Text = $"adrilight {GetVersionNumber()}",
193+
Text = $"adrilight {VersionNumber}",
194194
Icon = icon,
195195
Visible = true,
196196
ContextMenu = contextMenu
@@ -201,21 +201,9 @@ private void SetupNotifyIcon()
201201
}
202202

203203

204-
public static string VersionNumber { get; } = GetVersionNumber();
204+
public static string VersionNumber { get; } = Assembly.GetExecutingAssembly().GetName().Version.ToString(3);
205205
private IUserSettings UserSettings { get; set; }
206206

207-
private static string GetVersionNumber()
208-
{
209-
var assembly = Assembly.GetExecutingAssembly();
210-
string currentVersion;
211-
using (var versionStream = assembly.GetManifestResourceStream("adrilight.version.txt"))
212-
{
213-
currentVersion = new StreamReader(versionStream).ReadToEnd().Trim();
214-
}
215-
return currentVersion;
216-
}
217-
218-
219207
private void ApplicationWideException(object sender, Exception ex, string eventSource)
220208
{
221209
_log.Fatal(ex, $"ApplicationWideException from sender={sender}, adrilight version={VersionNumber}, eventSource={eventSource}");
@@ -238,7 +226,14 @@ private void ApplicationWideException(object sender, Exception ex, string eventS
238226
} while (ex != null);
239227

240228
MessageBox.Show(sb.ToString(), "unhandled exception :-(");
241-
Shutdown(-1);
229+
try
230+
{
231+
Shutdown(-1);
232+
}
233+
catch
234+
{
235+
Environment.Exit(-1);
236+
}
242237
}
243238
}
244239
}

adrilight/Util/AdrilightUpdater.cs

Lines changed: 17 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Newtonsoft.Json;
33
using NLog;
44
using Semver;
5+
using Squirrel;
56
using System;
67
using System.Collections.Generic;
78
using System.Diagnostics;
@@ -18,6 +19,8 @@ class AdrilightUpdater
1819
{
1920
private readonly ILogger _log = LogManager.GetCurrentClassLogger();
2021

22+
private const string ADRILIGHT_RELEASES = "https://fabse.net/adrilight/Releases";
23+
2124
public AdrilightUpdater(IUserSettings settings, IContext context)
2225
{
2326
Settings = settings ?? throw new ArgumentNullException(nameof(settings));
@@ -26,7 +29,7 @@ public AdrilightUpdater(IUserSettings settings, IContext context)
2629

2730
public void StartThread()
2831
{
29-
var t = new Thread(async () => await StartVersionCheck())
32+
var t = new Thread(async () => await StartSquirrel())
3033
{
3134
Name = "adrilight Update Checker",
3235
IsBackground = true,
@@ -38,72 +41,27 @@ public void StartThread()
3841
public IUserSettings Settings { get; }
3942
public IContext Context { get; }
4043

41-
private async Task StartVersionCheck()
44+
private async Task StartSquirrel()
4245
{
43-
//avoid too many checks
44-
if (Settings.LastUpdateCheck.HasValue && Settings.LastUpdateCheck > DateTime.UtcNow.AddHours(-8)) return;
45-
46-
try
46+
using (var mgr = new UpdateManager(ADRILIGHT_RELEASES))
4747
{
48-
var latestRelease = await TryGetLatestReleaseData();
49-
if (latestRelease == null) return;
48+
var releaseEntry = await mgr.UpdateApp();
5049

51-
string tagName = latestRelease.LatestVersionName;
52-
var latestVersionNumber = SemVersion.Parse(tagName.TrimStart('v', 'V'));
5350

54-
Settings.LastUpdateCheck = DateTime.UtcNow;
51+
//Context.Invoke(() =>
52+
//{
53+
// string message = $"New version of adrilight is available! The new version is {latestVersionNumber} (you are running {App.VersionNumber}). Press OK to open the download page!";
54+
// const string title = "New Adrilight Version!";
55+
// var shouldOpenUrl = MessageBox.Show(message, title, MessageBoxButton.OKCancel) == MessageBoxResult.OK;
5556

56-
if (latestVersionNumber > App.VersionNumber)
57-
{
58-
Context.Invoke(() =>
59-
{
60-
string message = $"New version of adrilight is available! The new version is {latestVersionNumber} (you are running {App.VersionNumber}). Press OK to open the download page!";
61-
const string title = "New Adrilight Version!";
62-
var shouldOpenUrl = MessageBox.Show(message, title, MessageBoxButton.OKCancel) == MessageBoxResult.OK;
57+
// if (shouldOpenUrl && latestRelease.LatestVersionUrl != null)
58+
// {
59+
// Process.Start(latestRelease.LatestVersionUrl);
60+
// }
61+
//});
6362

64-
if (shouldOpenUrl && latestRelease.LatestVersionUrl != null)
65-
{
66-
Process.Start(latestRelease.LatestVersionUrl);
67-
}
68-
});
69-
}
70-
}
71-
catch (Exception ex)
72-
{
73-
_log.Warn(ex, "Something failed in StartVersionCheck()");
74-
throw;
7563
}
76-
}
77-
78-
[DebuggerDisplay("GithubReleaseData: {LatestVersionName} {LatestVersionUrl}")]
79-
private class GithubReleaseData
80-
{
81-
[JsonProperty("tag_name")]
82-
public string LatestVersionName { get; set; }
83-
84-
[JsonProperty("html_url")]
85-
public string LatestVersionUrl { get; set; }
86-
}
87-
88-
private async Task<GithubReleaseData> TryGetLatestReleaseData()
89-
{
90-
try
91-
{
92-
using (var client = new HttpClient())
93-
{
94-
client.DefaultRequestHeaders.Add("User-Agent", "fabsenet/adrilight");
9564

96-
var jsonString = await client.GetStringAsync("https://api.github.com/repos/fabsenet/adrilight/releases/latest");
97-
var data = JsonConvert.DeserializeObject<GithubReleaseData>(jsonString);
98-
return data;
99-
}
100-
}
101-
catch (Exception ex)
102-
{
103-
_log.Info(ex, "Check for latest release failed.");
104-
return null;
105-
}
10665
}
107-
10866
}
10967
}

adrilight/adrilight.csproj

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@
7373
<Reference Include="CommonServiceLocator, Version=2.0.3.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
7474
<HintPath>..\packages\CommonServiceLocator.2.0.3\lib\net47\CommonServiceLocator.dll</HintPath>
7575
</Reference>
76+
<Reference Include="DeltaCompressionDotNet, Version=1.1.0.0, Culture=neutral, PublicKeyToken=1d14d6e5194e7f4a, processorArchitecture=MSIL">
77+
<HintPath>..\packages\DeltaCompressionDotNet.1.1.0\lib\net20\DeltaCompressionDotNet.dll</HintPath>
78+
</Reference>
79+
<Reference Include="DeltaCompressionDotNet.MsDelta, Version=1.1.0.0, Culture=neutral, PublicKeyToken=46b2138a390abf55, processorArchitecture=MSIL">
80+
<HintPath>..\packages\DeltaCompressionDotNet.1.1.0\lib\net20\DeltaCompressionDotNet.MsDelta.dll</HintPath>
81+
</Reference>
82+
<Reference Include="DeltaCompressionDotNet.PatchApi, Version=1.1.0.0, Culture=neutral, PublicKeyToken=3e8888ee913ed789, processorArchitecture=MSIL">
83+
<HintPath>..\packages\DeltaCompressionDotNet.1.1.0\lib\net20\DeltaCompressionDotNet.PatchApi.dll</HintPath>
84+
</Reference>
7685
<Reference Include="GalaSoft.MvvmLight, Version=5.4.1.0, Culture=neutral, PublicKeyToken=e7570ab207bcb616, processorArchitecture=MSIL">
7786
<HintPath>..\packages\MvvmLightLibs.5.4.1\lib\net45\GalaSoft.MvvmLight.dll</HintPath>
7887
</Reference>
@@ -109,6 +118,18 @@
109118
<Reference Include="Microsoft.ApplicationInsights.NLogTarget, Version=2.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
110119
<HintPath>..\packages\Microsoft.ApplicationInsights.NLogTarget.2.5.0\lib\net45\Microsoft.ApplicationInsights.NLogTarget.dll</HintPath>
111120
</Reference>
121+
<Reference Include="Mono.Cecil, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
122+
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.dll</HintPath>
123+
</Reference>
124+
<Reference Include="Mono.Cecil.Mdb, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
125+
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Mdb.dll</HintPath>
126+
</Reference>
127+
<Reference Include="Mono.Cecil.Pdb, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
128+
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Pdb.dll</HintPath>
129+
</Reference>
130+
<Reference Include="Mono.Cecil.Rocks, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
131+
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Rocks.dll</HintPath>
132+
</Reference>
112133
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
113134
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
114135
</Reference>
@@ -124,6 +145,9 @@
124145
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
125146
<HintPath>..\packages\NLog.4.5.2\lib\net45\NLog.dll</HintPath>
126147
</Reference>
148+
<Reference Include="NuGet.Squirrel, Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL">
149+
<HintPath>..\packages\squirrel.windows.1.7.9\lib\Net45\NuGet.Squirrel.dll</HintPath>
150+
</Reference>
127151
<Reference Include="Polly, Version=5.9.0.0, Culture=neutral, processorArchitecture=MSIL">
128152
<HintPath>..\packages\Polly.5.9.0\lib\net45\Polly.dll</HintPath>
129153
</Reference>
@@ -132,6 +156,9 @@
132156
<Reference Include="Semver, Version=2.0.4.0, Culture=neutral, processorArchitecture=MSIL">
133157
<HintPath>..\packages\Semver.2.0.4\lib\net452\Semver.dll</HintPath>
134158
</Reference>
159+
<Reference Include="SharpCompress, Version=0.17.1.0, Culture=neutral, PublicKeyToken=afb0a02973931d96, processorArchitecture=MSIL">
160+
<HintPath>..\packages\SharpCompress.0.17.1\lib\net45\SharpCompress.dll</HintPath>
161+
</Reference>
135162
<Reference Include="SharpDX, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
136163
<HintPath>..\packages\SharpDX.4.0.1\lib\net45\SharpDX.dll</HintPath>
137164
</Reference>
@@ -141,6 +168,12 @@
141168
<Reference Include="SharpDX.DXGI, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
142169
<HintPath>..\packages\SharpDX.DXGI.4.0.1\lib\net45\SharpDX.DXGI.dll</HintPath>
143170
</Reference>
171+
<Reference Include="Splat, Version=1.6.2.0, Culture=neutral, processorArchitecture=MSIL">
172+
<HintPath>..\packages\Splat.1.6.2\lib\Net45\Splat.dll</HintPath>
173+
</Reference>
174+
<Reference Include="Squirrel, Version=1.7.9.0, Culture=neutral, processorArchitecture=MSIL">
175+
<HintPath>..\packages\squirrel.windows.1.7.9\lib\Net45\Squirrel.dll</HintPath>
176+
</Reference>
144177
<Reference Include="System" />
145178
<Reference Include="System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
146179
<HintPath>..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll</HintPath>
@@ -195,6 +228,7 @@
195228
<Compile Include="Settings\IUserSettings.cs" />
196229
<Compile Include="Settings\UserSettings.cs" />
197230
<Compile Include="Messaging\TraceFrameMessage.cs" />
231+
<None Include="adrilight.nuspec" />
198232
<None Include="ApplicationInsights.config">
199233
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
200234
</None>
@@ -238,9 +272,6 @@
238272
<DependentUpon>SettingsWindow.xaml</DependentUpon>
239273
</Compile>
240274
<Compile Include="ViewModel\ViewModelLocator.cs" />
241-
<EmbeddedResource Include="..\version.txt">
242-
<Link>version.txt</Link>
243-
</EmbeddedResource>
244275
<Resource Include="View\Images\adrilight_icon.ico" />
245276
<Content Include="NLog.config">
246277
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
@@ -317,4 +348,11 @@
317348
<Target Name="AfterBuild">
318349
</Target>
319350
-->
351+
<Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Release'">
352+
<GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
353+
<Output TaskParameter="Assemblies" ItemName="myAssemblyInfo" />
354+
</GetAssemblyIdentity>
355+
<Exec Command="nuget pack adrilight.nuspec -Version %(myAssemblyInfo.Version) -Properties Configuration=Release -OutputDirectory $(OutDir) -BasePath $(OutDir)" />
356+
<Exec Command="squirrel --framework-version=net471 --releasify $(OutDir)adrilight.$([System.Version]::Parse(%(myAssemblyInfo.Version)).ToString(3)).nupkg" />
357+
</Target>
320358
</Project>

adrilight/adrilight.nuspec

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
3+
<metadata>
4+
<id>adrilight</id>
5+
<!-- version will be replaced by MSBuild -->
6+
<version>0.0.0.0</version>
7+
<title>adrilight</title>
8+
<authors>fabsenet</authors>
9+
<description>description</description>
10+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
11+
<copyright>Copyright 2018</copyright>
12+
<dependencies />
13+
</metadata>
14+
<files>
15+
<file src="*.*" target="lib\net45\" exclude="*.pdb;*.nupkg;*.vshost.*"/>
16+
</files>
17+
</package>

adrilight/packages.config

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<packages>
33
<package id="Castle.Core" version="4.2.1" targetFramework="net471" />
44
<package id="CommonServiceLocator" version="2.0.3" targetFramework="net471" />
5+
<package id="DeltaCompressionDotNet" version="1.1.0" targetFramework="net471" />
56
<package id="MaterialDesignColors" version="1.1.3" targetFramework="net471" />
67
<package id="MaterialDesignThemes" version="2.4.0.1044" targetFramework="net471" />
78
<package id="Microsoft.ApplicationInsights" version="2.5.1" targetFramework="net471" />
@@ -11,6 +12,7 @@
1112
<package id="Microsoft.ApplicationInsights.PerfCounterCollector" version="2.5.1" targetFramework="net471" />
1213
<package id="Microsoft.ApplicationInsights.WindowsServer" version="2.5.1" targetFramework="net471" />
1314
<package id="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel" version="2.5.1" targetFramework="net471" />
15+
<package id="Mono.Cecil" version="0.9.6.1" targetFramework="net471" />
1416
<package id="MvvmLight" version="5.4.1" targetFramework="net471" />
1517
<package id="MvvmLightLibs" version="5.4.1" targetFramework="net471" />
1618
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net471" />
@@ -22,9 +24,12 @@
2224
<package id="NLog.Schema" version="4.5.2" targetFramework="net471" />
2325
<package id="Polly" version="5.9.0" targetFramework="net471" />
2426
<package id="Semver" version="2.0.4" targetFramework="net47" />
27+
<package id="SharpCompress" version="0.17.1" targetFramework="net471" />
2528
<package id="SharpDX" version="4.0.1" targetFramework="net471" />
2629
<package id="SharpDX.Direct3D11" version="4.0.1" targetFramework="net471" />
2730
<package id="SharpDX.DXGI" version="4.0.1" targetFramework="net471" />
31+
<package id="Splat" version="1.6.2" targetFramework="net471" />
32+
<package id="squirrel.windows" version="1.7.9" targetFramework="net471" />
2833
<package id="System.Buffers" version="4.4.0" targetFramework="net471" />
2934
<package id="System.Diagnostics.DiagnosticSource" version="4.4.0" targetFramework="net471" />
3035
</packages>

assets/Web.config

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<configuration>
3+
<system.webServer>
4+
<staticContent>
5+
<mimeMap fileExtension=".nupkg" mimeType="application/zip" />
6+
<mimeMap fileExtension="." mimeType="text/plain" />
7+
</staticContent>
8+
</system.webServer>
9+
</configuration>

create_release.bat

Lines changed: 0 additions & 3 deletions
This file was deleted.

create_release.ps1

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)