diff --git a/build.cake b/build.cake index 4e0480d..f1e0aab 100644 --- a/build.cake +++ b/build.cake @@ -32,6 +32,7 @@ Task("Clean") { CleanDirectory("./.artifacts"); CleanDirectory("./.artifacts/bin"); + CleanDirectory("./.artifacts/appx"); CleanDirectory("./.artifacts/installer"); CleanDirectory("./.artifacts/installer/bin"); }); @@ -58,12 +59,28 @@ Task("Patch-Version") }); }); +Task("Patch-AppX-Info") + .WithCriteria(() => patch) + .Does(() => +{ + var manifest = File("./src/Jarvis.Package/Package.appxmanifest"); + var settings = new XmlPokeSettings + { + Namespaces = {{ "c", "http://schemas.microsoft.com/appx/manifest/foundation/windows10" }} + }; + + XmlPoke(manifest, "c:Package/c:Identity/@Version", $"{version.MsiVersion}.0", settings); +}); + Task("Build") .IsDependentOn("Restore") .IsDependentOn("Patch-Version") + .IsDependentOn("Patch-AppX-Info") .Does(() => { MSBuild("./src/Jarvis.sln", new MSBuildSettings() + .WithProperty("AppxBundlePlatforms", "neutral") + .WithProperty("AppxBundle", "Always") .SetConfiguration(configuration) .SetVerbosity(Verbosity.Minimal)); }); @@ -81,6 +98,7 @@ Task("Copy-Binaries") { CopyFiles($"./src/Jarvis/bin/{configuration}/*", "./.artifacts/bin"); CopyFiles($"./src/Jarvis/bin/{configuration}/*", "./.artifacts/installer/bin"); + CopyFiles($"./src/Jarvis.Package/AppPackages/Jarvis.Package_{version.MsiVersion}.0_*/**/*", "./.artifacts/appx"); DeleteFiles("./.artifacts/installer/bin/*.xml"); DeleteFiles("./.artifacts/installer/bin/*.pdb"); diff --git a/build.ps1 b/build.ps1 index ab5a17e..7c792c0 100644 --- a/build.ps1 +++ b/build.ps1 @@ -2,7 +2,7 @@ $ENV:CAKE_NUGET_USEINPROCESSCLIENT='true' $ToolPath = Join-Path $PSScriptRoot "tools" $NugetPath = Join-Path $ToolPath "nuget.exe" $NugetUrl = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -$CakeVersion = "0.25.0" +$CakeVersion = "0.30.0" # Make sure tools folder exists $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent @@ -29,9 +29,7 @@ Function Unzip [System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath) } - # Make sure Cake has been installed. -#https://www.nuget.org/api/v2/package $NugetFeed = 'https://www.myget.org/F/cake/api/v2/package' $CakePath = Join-Path $ToolPath "cake.$CakeVersion/Cake.exe" diff --git a/src/Jarvis.Addin.Files/Indexing/FileIndexer.cs b/src/Jarvis.Addin.Files/Indexing/FileIndexer.cs index a0e8693..2701012 100644 --- a/src/Jarvis.Addin.Files/Indexing/FileIndexer.cs +++ b/src/Jarvis.Addin.Files/Indexing/FileIndexer.cs @@ -45,6 +45,11 @@ public FileIndexer(IEventAggregator events, IEnumerable source events.Subscribe(this); } + public bool Enabled() + { + return true; + } + public Task Run(CancellationToken token) { return Task.Run(() => diff --git a/src/Jarvis.Core/Threading/IBackgroundWorker.cs b/src/Jarvis.Core/Threading/IBackgroundWorker.cs index aeedc92..cb5d0fe 100644 --- a/src/Jarvis.Core/Threading/IBackgroundWorker.cs +++ b/src/Jarvis.Core/Threading/IBackgroundWorker.cs @@ -10,6 +10,7 @@ namespace Jarvis.Core.Threading public interface IBackgroundWorker { string Name { get; } + bool Enabled(); Task Run(CancellationToken token); } } \ No newline at end of file diff --git a/src/Jarvis.Package/Jarvis.Package.wapproj b/src/Jarvis.Package/Jarvis.Package.wapproj index 2382775..520d78b 100644 --- a/src/Jarvis.Package/Jarvis.Package.wapproj +++ b/src/Jarvis.Package/Jarvis.Package.wapproj @@ -1,25 +1,10 @@ - + 15.0 + neutral - - Debug - x86 - - - Release - x86 - - - Debug - x64 - - - Release - x64 - Debug AnyCPU @@ -40,6 +25,7 @@ en-US Jarvis.Package_TemporaryKey.pfx ..\Jarvis\Jarvis.csproj + E018FA042C858503529CA2F55A2CF3B1BB569312 diff --git a/src/Jarvis.Package/Jarvis.Package_TemporaryKey.pfx b/src/Jarvis.Package/Jarvis.Package_TemporaryKey.pfx index a0de7b7..fc5eed4 100644 Binary files a/src/Jarvis.Package/Jarvis.Package_TemporaryKey.pfx and b/src/Jarvis.Package/Jarvis.Package_TemporaryKey.pfx differ diff --git a/src/Jarvis.Package/Package.appxmanifest b/src/Jarvis.Package/Package.appxmanifest index b00d622..c5bc4a9 100644 --- a/src/Jarvis.Package/Package.appxmanifest +++ b/src/Jarvis.Package/Package.appxmanifest @@ -1,9 +1,9 @@  - + - Jarvis - SpectreSystems + Jarvis - Your robotic butler + Spectre Systems AB Images\StoreLogo.png diff --git a/src/Jarvis.sln b/src/Jarvis.sln index 18b7768..63cdc7d 100644 --- a/src/Jarvis.sln +++ b/src/Jarvis.sln @@ -104,21 +104,21 @@ Global {121A7682-EDCA-4031-B9BF-3B01EA6675DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {121A7682-EDCA-4031-B9BF-3B01EA6675DD}.Debug|Any CPU.Build.0 = Debug|Any CPU {121A7682-EDCA-4031-B9BF-3B01EA6675DD}.Debug|Any CPU.Deploy.0 = Debug|Any CPU - {121A7682-EDCA-4031-B9BF-3B01EA6675DD}.Debug|x64.ActiveCfg = Debug|x64 - {121A7682-EDCA-4031-B9BF-3B01EA6675DD}.Debug|x64.Build.0 = Debug|x64 - {121A7682-EDCA-4031-B9BF-3B01EA6675DD}.Debug|x64.Deploy.0 = Debug|x64 - {121A7682-EDCA-4031-B9BF-3B01EA6675DD}.Debug|x86.ActiveCfg = Debug|x86 - {121A7682-EDCA-4031-B9BF-3B01EA6675DD}.Debug|x86.Build.0 = Debug|x86 - {121A7682-EDCA-4031-B9BF-3B01EA6675DD}.Debug|x86.Deploy.0 = Debug|x86 + {121A7682-EDCA-4031-B9BF-3B01EA6675DD}.Debug|x64.ActiveCfg = Debug|Any CPU + {121A7682-EDCA-4031-B9BF-3B01EA6675DD}.Debug|x64.Build.0 = Debug|Any CPU + {121A7682-EDCA-4031-B9BF-3B01EA6675DD}.Debug|x64.Deploy.0 = Debug|Any CPU + {121A7682-EDCA-4031-B9BF-3B01EA6675DD}.Debug|x86.ActiveCfg = Debug|Any CPU + {121A7682-EDCA-4031-B9BF-3B01EA6675DD}.Debug|x86.Build.0 = Debug|Any CPU + {121A7682-EDCA-4031-B9BF-3B01EA6675DD}.Debug|x86.Deploy.0 = Debug|Any CPU {121A7682-EDCA-4031-B9BF-3B01EA6675DD}.Release|Any CPU.ActiveCfg = Release|Any CPU {121A7682-EDCA-4031-B9BF-3B01EA6675DD}.Release|Any CPU.Build.0 = Release|Any CPU {121A7682-EDCA-4031-B9BF-3B01EA6675DD}.Release|Any CPU.Deploy.0 = Release|Any CPU - {121A7682-EDCA-4031-B9BF-3B01EA6675DD}.Release|x64.ActiveCfg = Release|x64 - {121A7682-EDCA-4031-B9BF-3B01EA6675DD}.Release|x64.Build.0 = Release|x64 - {121A7682-EDCA-4031-B9BF-3B01EA6675DD}.Release|x64.Deploy.0 = Release|x64 - {121A7682-EDCA-4031-B9BF-3B01EA6675DD}.Release|x86.ActiveCfg = Release|x86 - {121A7682-EDCA-4031-B9BF-3B01EA6675DD}.Release|x86.Build.0 = Release|x86 - {121A7682-EDCA-4031-B9BF-3B01EA6675DD}.Release|x86.Deploy.0 = Release|x86 + {121A7682-EDCA-4031-B9BF-3B01EA6675DD}.Release|x64.ActiveCfg = Release|Any CPU + {121A7682-EDCA-4031-B9BF-3B01EA6675DD}.Release|x64.Build.0 = Release|Any CPU + {121A7682-EDCA-4031-B9BF-3B01EA6675DD}.Release|x64.Deploy.0 = Release|Any CPU + {121A7682-EDCA-4031-B9BF-3B01EA6675DD}.Release|x86.ActiveCfg = Release|Any CPU + {121A7682-EDCA-4031-B9BF-3B01EA6675DD}.Release|x86.Build.0 = Release|Any CPU + {121A7682-EDCA-4031-B9BF-3B01EA6675DD}.Release|x86.Deploy.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Jarvis/Bootstrapping/JarvisModule.cs b/src/Jarvis/Bootstrapping/JarvisModule.cs index bfdd864..33babf7 100644 --- a/src/Jarvis/Bootstrapping/JarvisModule.cs +++ b/src/Jarvis/Bootstrapping/JarvisModule.cs @@ -9,6 +9,7 @@ using Jarvis.Bootstrapping.Seeding; using Jarvis.Core; using Jarvis.Core.Threading; +using Jarvis.Infrastructure.Utilities; using Jarvis.Services; using Jarvis.ViewModels; using Spectre.System.IO; @@ -27,7 +28,7 @@ protected override void Load(ContainerBuilder builder) // Core builder.RegisterType().As().SingleInstance(); - // Background services. + // Background services builder.RegisterType().SingleInstance(); builder.RegisterType().As().SingleInstance(); diff --git a/src/Jarvis/Infrastructure/Utilities/UwpUtility.cs b/src/Jarvis/Infrastructure/Utilities/UwpUtility.cs new file mode 100644 index 0000000..f715c55 --- /dev/null +++ b/src/Jarvis/Infrastructure/Utilities/UwpUtility.cs @@ -0,0 +1,50 @@ +// Licensed to Spectre Systems AB under one or more agreements. +// Spectre Systems AB licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +// --------------------------------------------------------------------- +// Copyright (c) 2015 Matteo Pagani, licensed under MIT +// https://github.com/qmatteoq/DesktopBridgeHelpers +// --------------------------------------------------------------------- + +using System; +using System.Runtime.InteropServices; +using System.Text; + +namespace Jarvis.Infrastructure.Utilities +{ + public static class UwpUtility + { + [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] + public static extern int GetCurrentPackageFullName(ref int packageFullNameLength, StringBuilder packageFullName); + + public static bool IsRunningAsUwp() + { + if (IsWindows7OrLower) + { + return false; + } + else + { + int length = 0; + var builder = new StringBuilder(0); + int result = GetCurrentPackageFullName(ref length, builder); + + builder = new StringBuilder(length); + result = GetCurrentPackageFullName(ref length, builder); + + return result != 15700L; + } + } + + private static bool IsWindows7OrLower + { + get + { + int versionMajor = Environment.OSVersion.Version.Major; + int versionMinor = Environment.OSVersion.Version.Minor; + double version = versionMajor + ((double)versionMinor / 10); + return version <= 6.1; + } + } + } +} diff --git a/src/Jarvis/Jarvis.csproj b/src/Jarvis/Jarvis.csproj index 6bdc8ec..2b87e3d 100644 --- a/src/Jarvis/Jarvis.csproj +++ b/src/Jarvis/Jarvis.csproj @@ -130,6 +130,7 @@ + JarvisApplication.xaml @@ -165,7 +166,7 @@ - + @@ -204,7 +205,7 @@ Designer MSBuild:Compile - + Designer MSBuild:Compile diff --git a/src/Jarvis/Services/ApplicationService.cs b/src/Jarvis/Services/ApplicationService.cs index e32db21..d63a71a 100644 --- a/src/Jarvis/Services/ApplicationService.cs +++ b/src/Jarvis/Services/ApplicationService.cs @@ -22,6 +22,11 @@ public ApplicationService( _application = application; } + public bool IsRunningAsUwp() + { + return UwpUtility.IsRunningAsUwp(); + } + public bool IsWindowsShuttingDown() { return Win32.System.GetSystemMetrics(Win32.System.W32SystemMetric.ShuttingDown) != 0; diff --git a/src/Jarvis/Services/ServiceOrchestrator.cs b/src/Jarvis/Services/ServiceOrchestrator.cs index 1119887..fa73c65 100644 --- a/src/Jarvis/Services/ServiceOrchestrator.cs +++ b/src/Jarvis/Services/ServiceOrchestrator.cs @@ -43,6 +43,12 @@ public void Start() // Start all tasks. foreach (var worker in _workers) { + if (!worker.Enabled()) + { + _log.Information($"Service {worker.Name} will not be started."); + continue; + } + _tasks.Add(new TaskWrapper(worker, _log).Start(_source)); } diff --git a/src/Jarvis/Services/UpdateService.cs b/src/Jarvis/Services/UpdateService.cs index 8e13a33..c3b9439 100644 --- a/src/Jarvis/Services/UpdateService.cs +++ b/src/Jarvis/Services/UpdateService.cs @@ -19,19 +19,26 @@ public sealed class UpdateService : IBackgroundWorker private readonly IUpdateChecker _checker; private readonly ISettingsStore _settings; private readonly IEventAggregator _eventAggregator; + private readonly ApplicationService _application; private readonly IJarvisLog _log; public string Name => "Update service"; public UpdateService(IUpdateChecker checker, ISettingsStore settings, - IEventAggregator eventAggregator, IJarvisLog log) + IEventAggregator eventAggregator, ApplicationService application, IJarvisLog log) { _checker = checker; _settings = settings; _eventAggregator = eventAggregator; + _application = application; _log = new LogDecorator("UpdateService", log); } + public bool Enabled() + { + return !_application.IsRunningAsUwp(); + } + public async Task Run(CancellationToken token) { #if !DEBUG diff --git a/src/Jarvis/ViewModels/Settings/GeneralSettingsViewModel.cs b/src/Jarvis/ViewModels/Settings/UpdateSettingsViewModel.cs similarity index 90% rename from src/Jarvis/ViewModels/Settings/GeneralSettingsViewModel.cs rename to src/Jarvis/ViewModels/Settings/UpdateSettingsViewModel.cs index 722aa94..4800f8d 100644 --- a/src/Jarvis/ViewModels/Settings/GeneralSettingsViewModel.cs +++ b/src/Jarvis/ViewModels/Settings/UpdateSettingsViewModel.cs @@ -7,9 +7,9 @@ namespace Jarvis.ViewModels.Settings { - public sealed class GeneralSettingsViewModel : Screen, ISettings + public sealed class UpdateSettingsViewModel : Screen, ISettings { - public string Name => "General"; + public string Name => "Update"; public bool CheckForUpdates { get; set; } public bool IncludePreviews { get; set; } diff --git a/src/Jarvis/ViewModels/SettingsViewModel.cs b/src/Jarvis/ViewModels/SettingsViewModel.cs index 2bda8c7..09bd676 100644 --- a/src/Jarvis/ViewModels/SettingsViewModel.cs +++ b/src/Jarvis/ViewModels/SettingsViewModel.cs @@ -15,16 +15,26 @@ namespace Jarvis.ViewModels { public sealed class SettingsViewModel : Conductor.Collection.OneActive { + private readonly ApplicationService _application; private readonly SettingsService _settings; public delegate SettingsViewModel Factory(); public string ValidationMessage { get; set; } - public SettingsViewModel(IEnumerable providers, SettingsService settings, ILifetimeScope scope) + public SettingsViewModel( + IEnumerable providers, ApplicationService application, + SettingsService settings, ILifetimeScope scope) { + _application = application; _settings = settings; - Items.Add(new GeneralSettingsViewModel()); + + if (application.IsRunningAsUwp()) + { + // Only show update settings if not running + // as an UWP application. + Items.Add(new UpdateSettingsViewModel()); + } foreach (var provider in providers) { diff --git a/src/Jarvis/Views/Settings/GeneralSettingsView.xaml b/src/Jarvis/Views/Settings/UpdateSettingsView.xaml similarity index 90% rename from src/Jarvis/Views/Settings/GeneralSettingsView.xaml rename to src/Jarvis/Views/Settings/UpdateSettingsView.xaml index b0e8028..40a4d00 100644 --- a/src/Jarvis/Views/Settings/GeneralSettingsView.xaml +++ b/src/Jarvis/Views/Settings/UpdateSettingsView.xaml @@ -1,4 +1,4 @@ -