Skip to content

Commit

Permalink
Updated source packages and build config
Browse files Browse the repository at this point in the history
  • Loading branch information
i8beef committed Dec 30, 2019
1 parent b3ba9a9 commit db72088
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 32 deletions.
28 changes: 28 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: 1.0.0.{build}
branches:
only:
- master
skip_tags: true
image: Visual Studio 2019
dotnet_csproj:
patch: true
file: '**\*.csproj'
version: '{version}'
version_prefix: '{version}'
package_version: '{version}'
assembly_version: '{version}'
file_version: '{version}'
informational_version: '{version}'
build_script:
- ps: >-
dotnet restore src/HomeAutio.Mqtt.TiVo.sln
dotnet publish -c Release src/HomeAutio.Mqtt.TiVo.sln
artifacts:
- path: src\HomeAutio.Mqtt.TiVo\bin\$(configuration)\netcoreapp3.1\publish
name: HomeAutio.Mqtt.TiVo-$(appveyor_build_version)
deploy:
- provider: GitHub
auth_token:
secure: t8wH1tV0xPU25FeKde96GGBYZIcWVhBy7VuIJujTodtx1FSQzlI0AEOPHLKyPORa
artifact: src\HomeAutio.Mqtt.TiVo\bin\$(configuration)\netcoreapp3.1\HomeAutio.Mqtt.TiVo-$(appveyor_build_version).zip
4 changes: 2 additions & 2 deletions src/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM microsoft/dotnet:2.1-sdk-alpine AS build
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine AS build
WORKDIR /app

# copy csproj and restore as distinct layers
Expand All @@ -17,7 +17,7 @@ WORKDIR /app/HomeAutio.Mqtt.TiVo
RUN dotnet publish -o out

# build runtime image
FROM microsoft/dotnet:2.1-runtime-alpine AS runtime
FROM mcr.microsoft.com/dotnet/core/runtime:3.1-alpine AS runtime
WORKDIR /app
COPY --from=publish /app/HomeAutio.Mqtt.TiVo/out ./

Expand Down
4 changes: 2 additions & 2 deletions src/Dockerfile.arm32
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM microsoft/dotnet:2.1-sdk-alpine AS build
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine AS build
WORKDIR /app

# copy csproj and restore as distinct layers
Expand All @@ -17,7 +17,7 @@ WORKDIR /app/HomeAutio.Mqtt.TiVo
RUN dotnet publish -o out

# build runtime image
FROM microsoft/dotnet:2.1-aspnetcore-runtime-stretch-slim-arm32v7 AS runtime
FROM mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim-arm32v7 AS runtime
WORKDIR /app
COPY --from=publish /app/HomeAutio.Mqtt.TiVo/out ./

Expand Down
15 changes: 8 additions & 7 deletions src/HomeAutio.Mqtt.TiVo/HomeAutio.Mqtt.TiVo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<LangVersion>latest</LangVersion>
<PackageProjectUrl>https://github.com/i8beef/HomeAutio.Mqtt.TiVo</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/i8beef/HomeAutio.Mqtt.TiVo/blob/master/LICENSE</PackageLicenseUrl>
<Company></Company>
Expand All @@ -29,13 +30,13 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="HomeAutio.Mqtt.Core" Version="3.0.0.51" />
<PackageReference Include="HomeAutio.Mqtt.Core" Version="3.0.0.55" />
<PackageReference Include="I8Beef.CodeAnalysis.RuleSet" Version="1.0.15" />
<PackageReference Include="I8Beef.TiVo" Version="1.0.0.8" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="2.1.1" />
<PackageReference Include="Serilog.Extensions.Logging" Version="2.0.2" />
<PackageReference Include="Serilog.Settings.Configuration" Version="2.6.1" />
<PackageReference Include="I8Beef.TiVo" Version="1.0.0.10" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="3.0.1" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.RollingFile" Version="3.3.0" />
</ItemGroup>
Expand Down
12 changes: 1 addition & 11 deletions src/HomeAutio.Mqtt.TiVo/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,8 @@ public class Program
/// <summary>
/// Main program entry point.
/// </summary>
/// <param name="args">Arguments.</param>
public static void Main(string[] args)
{
MainAsync(args).GetAwaiter().GetResult();
}

/// <summary>
/// Main program entry point.
/// </summary>
/// <param name="args">Arguments.</param>
/// <returns>Awaitable <see cref="Task" />.</returns>
public static async Task MainAsync(string[] args)
public static async Task Main()
{
var environmentName = Environment.GetEnvironmentVariable("ENVIRONMENT");
if (string.IsNullOrEmpty(environmentName))
Expand Down
16 changes: 6 additions & 10 deletions src/HomeAutio.Mqtt.TiVo/TiVoMqttService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using I8Beef.TiVo.Responses;
using Microsoft.Extensions.Logging;
using MQTTnet;
using MQTTnet.Extensions.ManagedClient;

namespace HomeAutio.Mqtt.TiVo
{
Expand All @@ -15,12 +16,10 @@ namespace HomeAutio.Mqtt.TiVo
/// </summary>
public class TiVoMqttService : ServiceBase
{
private ILogger<TiVoMqttService> _log;
private readonly ILogger<TiVoMqttService> _log;
private readonly IClient _client;
private bool _disposed = false;

private IClient _client;
private string _tivoName;

/// <summary>
/// Initializes a new instance of the <see cref="TiVoMqttService"/> class.
/// </summary>
Expand All @@ -39,8 +38,6 @@ public TiVoMqttService(
SubscribedTopics.Add(TopicRoot + "/controls/+/set");

_client = tivoClient;
_tivoName = tivoName;

_client.EventReceived += TiVo_EventReceived;

// TiVo client logging
Expand All @@ -57,15 +54,15 @@ public TiVoMqttService(
#region Service implementation

/// <inheritdoc />
protected override Task StartServiceAsync(CancellationToken cancellationToken = default(CancellationToken))
protected override Task StartServiceAsync(CancellationToken cancellationToken = default)
{
_client.Connect();

return Task.CompletedTask;
}

/// <inheritdoc />
protected override Task StopServiceAsync(CancellationToken cancellationToken = default(CancellationToken))
protected override Task StopServiceAsync(CancellationToken cancellationToken = default)
{
return Task.CompletedTask;
}
Expand All @@ -77,9 +74,8 @@ public TiVoMqttService(
/// <summary>
/// Handles commands for the TiVo published to MQTT.
/// </summary>
/// <param name="sender">Event sender.</param>
/// <param name="e">Event args.</param>
protected override async void Mqtt_MqttMsgPublishReceived(object sender, MqttApplicationMessageReceivedEventArgs e)
protected override async void Mqtt_MqttMsgPublishReceived(MqttApplicationMessageReceivedEventArgs e)
{
var message = e.ApplicationMessage.ConvertPayloadToString();
_log.LogInformation("MQTT message received for topic " + e.ApplicationMessage.Topic + ": " + message);
Expand Down

0 comments on commit db72088

Please sign in to comment.