Skip to content

Commit 7911024

Browse files
committed
Updated build configuration and a few code cleanup tasks
1 parent 18f9ed3 commit 7911024

File tree

4 files changed

+45
-29
lines changed

4 files changed

+45
-29
lines changed

appveyor.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
version: 1.0.0.{build}
2+
branches:
3+
only:
4+
- master
5+
skip_tags: true
6+
image: Visual Studio 2019
7+
configuration: Release
8+
dotnet_csproj:
9+
patch: true
10+
file: '**\*.csproj'
11+
version: '{version}'
12+
version_prefix: '{version}'
13+
package_version: '{version}'
14+
assembly_version: '{version}'
15+
file_version: '{version}'
16+
informational_version: '{version}'
17+
build_script:
18+
- ps: >-
19+
dotnet restore src/HomeAutio.Mqtt.Ecobee.sln
20+
21+
dotnet publish -c Release src/HomeAutio.Mqtt.Ecobee.sln
22+
artifacts:
23+
- path: src\HomeAutio.Mqtt.Ecobee\bin\$(configuration)\netcoreapp3.1\publish
24+
name: HomeAutio.Mqtt.Ecobee-$(appveyor_build_version)
25+
deploy:
26+
- provider: GitHub
27+
auth_token: $(GITHUB_API_KEY)
28+
artifact: src\HomeAutio.Mqtt.Ecobee\bin\$(configuration)\netcoreapp3.1\HomeAutio.Mqtt.Ecobee-$(appveyor_build_version).zip

src/HomeAutio.Mqtt.Ecobee/EcobeeMqttService.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using I8Beef.Ecobee.Protocol.Thermostat;
1313
using Microsoft.Extensions.Logging;
1414
using MQTTnet;
15+
using MQTTnet.Extensions.ManagedClient;
1516

1617
namespace HomeAutio.Mqtt.Ecobee
1718
{
@@ -23,14 +24,13 @@ public class EcobeeMqttService : ServiceBase
2324
private readonly ILogger<EcobeeMqttService> _log;
2425

2526
private readonly Client _client;
26-
private readonly string _ecobeeName;
2727

2828
private readonly IDictionary<string, RevisionStatus> _revisionStatusCache;
2929
private readonly IDictionary<string, ThermostatStatus> _thermostatStatus;
30+
private readonly int _refreshInterval;
3031

3132
private bool _disposed = false;
3233
private System.Timers.Timer _refresh;
33-
private int _refreshInterval;
3434

3535
/// <summary>
3636
/// Initializes a new instance of the <see cref="EcobeeMqttService"/> class.
@@ -53,15 +53,14 @@ public EcobeeMqttService(
5353
SubscribedTopics.Add(TopicRoot + "/+/+/set");
5454

5555
_client = ecobeeClient;
56-
_ecobeeName = ecobeeName;
5756
_revisionStatusCache = new Dictionary<string, RevisionStatus>();
5857
_thermostatStatus = new Dictionary<string, ThermostatStatus>();
5958
}
6059

6160
#region Service implementation
6261

6362
/// <inheritdoc />
64-
protected override async Task StartServiceAsync(CancellationToken cancellationToken = default(CancellationToken))
63+
protected override async Task StartServiceAsync(CancellationToken cancellationToken = default)
6564
{
6665
await GetInitialStatusAsync()
6766
.ConfigureAwait(false);
@@ -79,7 +78,7 @@ await GetInitialStatusAsync()
7978
}
8079

8180
/// <inheritdoc />
82-
protected override Task StopServiceAsync(CancellationToken cancellationToken = default(CancellationToken))
81+
protected override Task StopServiceAsync(CancellationToken cancellationToken = default)
8382
{
8483
return Task.CompletedTask;
8584
}
@@ -91,9 +90,8 @@ await GetInitialStatusAsync()
9190
/// <summary>
9291
/// Handles commands for the Harmony published to MQTT.
9392
/// </summary>
94-
/// <param name="sender">Event sender.</param>
9593
/// <param name="e">Event args.</param>
96-
protected override async void Mqtt_MqttMsgPublishReceived(object sender, MqttApplicationMessageReceivedEventArgs e)
94+
protected override async void Mqtt_MqttMsgPublishReceived(MqttApplicationMessageReceivedEventArgs e)
9795
{
9896
var message = Encoding.UTF8.GetString(e.ApplicationMessage.Payload);
9997
_log.LogInformation("MQTT message received for topic " + e.ApplicationMessage.Topic + ": " + message);

src/HomeAutio.Mqtt.Ecobee/HomeAutio.Mqtt.Ecobee.csproj

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp2.1</TargetFramework>
5+
<TargetFramework>netcoreapp3.1</TargetFramework>
66
<PackageProjectUrl>https://github.com/i8beef/HomeAutio.Mqtt.Ecobee</PackageProjectUrl>
77
<PackageLicenseUrl>https://github.com/i8beef/HomeAutio.Mqtt.Ecobee/blob/master/LICENSE</PackageLicenseUrl>
88
<Company></Company>
@@ -15,11 +15,11 @@
1515
</PropertyGroup>
1616

1717
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
18-
<DocumentationFile>bin\Debug\netcoreapp2.1\HomeAutio.Mqtt.Ecobee.xml</DocumentationFile>
18+
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
1919
</PropertyGroup>
2020

2121
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
22-
<DocumentationFile>bin\Release\netcoreapp2.1\HomeAutio.Mqtt.Ecobee.xml</DocumentationFile>
22+
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
2323
</PropertyGroup>
2424

2525
<ItemGroup>
@@ -32,12 +32,12 @@
3232
<PackageReference Include="I8Beef.CodeAnalysis.RuleSet" Version="1.0.15">
3333
<PrivateAssets>all</PrivateAssets>
3434
</PackageReference>
35-
<PackageReference Include="HomeAutio.Mqtt.Core" Version="3.0.0.51" />
36-
<PackageReference Include="I8Beef.Ecobee" Version="2.2.0.66" />
37-
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" />
38-
<PackageReference Include="Microsoft.Extensions.Hosting" Version="2.1.1" />
39-
<PackageReference Include="Serilog.Extensions.Logging" Version="2.0.2" />
40-
<PackageReference Include="Serilog.Settings.Configuration" Version="2.6.1" />
35+
<PackageReference Include="HomeAutio.Mqtt.Core" Version="3.0.0.57" />
36+
<PackageReference Include="I8Beef.Ecobee" Version="2.2.0.68" />
37+
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.3" />
38+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.3" />
39+
<PackageReference Include="Serilog.Extensions.Logging" Version="3.0.1" />
40+
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
4141
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
4242
<PackageReference Include="Serilog.Sinks.RollingFile" Version="3.3.0" />
4343
</ItemGroup>

src/HomeAutio.Mqtt.Ecobee/Program.cs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,8 @@ public class Program
2424
/// <summary>
2525
/// Main program entry point.
2626
/// </summary>
27-
/// <param name="args">Arguments.</param>
28-
public static void Main(string[] args)
29-
{
30-
MainAsync(args).GetAwaiter().GetResult();
31-
}
32-
33-
/// <summary>
34-
/// Main program entry point.
35-
/// </summary>
36-
/// <param name="args">Arguments.</param>
3727
/// <returns>Awaitable <see cref="Task" />.</returns>
38-
public static async Task MainAsync(string[] args)
28+
public static async Task Main()
3929
{
4030
var environmentName = Environment.GetEnvironmentVariable("ENVIRONMENT");
4131
if (string.IsNullOrEmpty(environmentName))
@@ -163,7 +153,7 @@ private static IHostBuilder CreateHostBuilder(IConfiguration config)
163153
/// <param name="storedAuthToken">Stored auth token.</param>
164154
/// <param name="cancellationToken">Cancellation token.</param>
165155
/// <returns>An awaitable <see cref="Task"/>.</returns>
166-
private static async Task WriteTokenFileAsync(StoredAuthToken storedAuthToken, CancellationToken cancellationToken = default(CancellationToken))
156+
private static async Task WriteTokenFileAsync(StoredAuthToken storedAuthToken, CancellationToken cancellationToken = default)
167157
{
168158
// Cache the returned tokens
169159
_currentAuthToken = storedAuthToken;
@@ -182,7 +172,7 @@ private static IHostBuilder CreateHostBuilder(IConfiguration config)
182172
/// </summary>
183173
/// <param name="cancellationToken">Cancellation token.</param>
184174
/// <returns>The <see cref="StoredAuthToken"/>.</returns>
185-
private static async Task<StoredAuthToken> ReadTokenFileAsync(CancellationToken cancellationToken = default(CancellationToken))
175+
private static async Task<StoredAuthToken> ReadTokenFileAsync(CancellationToken cancellationToken = default)
186176
{
187177
if (_currentAuthToken == null && File.Exists(@"token.txt"))
188178
{

0 commit comments

Comments
 (0)