Skip to content

Commit

Permalink
(build) Fixes AppX packaging
Browse files Browse the repository at this point in the history
Also don't run update service under UWP mode.
  • Loading branch information
patriksvensson committed Oct 14, 2018
1 parent 8d08e82 commit 11dad1c
Show file tree
Hide file tree
Showing 18 changed files with 135 additions and 47 deletions.
18 changes: 18 additions & 0 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Task("Clean")
{
CleanDirectory("./.artifacts");
CleanDirectory("./.artifacts/bin");
CleanDirectory("./.artifacts/appx");
CleanDirectory("./.artifacts/installer");
CleanDirectory("./.artifacts/installer/bin");
});
Expand All @@ -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));
});
Expand All @@ -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");
Expand Down
4 changes: 1 addition & 3 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down
5 changes: 5 additions & 0 deletions src/Jarvis.Addin.Files/Indexing/FileIndexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public FileIndexer(IEventAggregator events, IEnumerable<IFileIndexSource> source
events.Subscribe(this);
}

public bool Enabled()
{
return true;
}

public Task<bool> Run(CancellationToken token)
{
return Task.Run(() =>
Expand Down
1 change: 1 addition & 0 deletions src/Jarvis.Core/Threading/IBackgroundWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Jarvis.Core.Threading
public interface IBackgroundWorker
{
string Name { get; }
bool Enabled();
Task<bool> Run(CancellationToken token);
}
}
20 changes: 3 additions & 17 deletions src/Jarvis.Package/Jarvis.Package.wapproj
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '15.0'">
<VisualStudioVersion>15.0</VisualStudioVersion>
<AppxBundlePlatforms>neutral</AppxBundlePlatforms>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x86">
<Configuration>Debug</Configuration>
<Platform>x86</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x86">
<Configuration>Release</Configuration>
<Platform>x86</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|AnyCPU">
<Configuration>Debug</Configuration>
<Platform>AnyCPU</Platform>
Expand All @@ -40,6 +25,7 @@
<DefaultLanguage>en-US</DefaultLanguage>
<PackageCertificateKeyFile>Jarvis.Package_TemporaryKey.pfx</PackageCertificateKeyFile>
<EntryPointProjectUniqueName>..\Jarvis\Jarvis.csproj</EntryPointProjectUniqueName>
<PackageCertificateThumbprint>E018FA042C858503529CA2F55A2CF3B1BB569312</PackageCertificateThumbprint>
</PropertyGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
Expand Down
Binary file modified src/Jarvis.Package/Jarvis.Package_TemporaryKey.pfx
Binary file not shown.
6 changes: 3 additions & 3 deletions src/Jarvis.Package/Package.appxmanifest
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" IgnorableNamespaces="uap mp rescap">
<Identity Name="e042f0a3-0e04-49d6-9f96-43eb02b90042" Publisher="CN=mpagani" Version="1.0.0.0" />
<Identity Name="SpectreSystemsAB.Jarvis-Yourroboticbutler" Publisher="CN=BD765503-99E8-40AA-91EC-B3E295890BB4" Version="0.9.10009.0" />
<Properties>
<DisplayName>Jarvis</DisplayName>
<PublisherDisplayName>SpectreSystems</PublisherDisplayName>
<DisplayName>Jarvis - Your robotic butler</DisplayName>
<PublisherDisplayName>Spectre Systems AB</PublisherDisplayName>
<Logo>Images\StoreLogo.png</Logo>
</Properties>
<Dependencies>
Expand Down
24 changes: 12 additions & 12 deletions src/Jarvis.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/Jarvis/Bootstrapping/JarvisModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,7 +28,7 @@ protected override void Load(ContainerBuilder builder)
// Core
builder.RegisterType<FileSystem>().As<IFileSystem>().SingleInstance();

// Background services.
// Background services
builder.RegisterType<ServiceOrchestrator>().SingleInstance();
builder.RegisterType<UpdateService>().As<IBackgroundWorker>().SingleInstance();

Expand Down
50 changes: 50 additions & 0 deletions src/Jarvis/Infrastructure/Utilities/UwpUtility.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
}
5 changes: 3 additions & 2 deletions src/Jarvis/Jarvis.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
<Compile Include="Infrastructure\DelegateCommand.cs" />
<Compile Include="Infrastructure\Diagnostics\SerilogLog.cs" />
<Compile Include="Infrastructure\Utilities\PathUtility.cs" />
<Compile Include="Infrastructure\Utilities\UwpUtility.cs" />
<Compile Include="Infrastructure\Utilities\WindowUtility.cs" />
<Compile Include="JarvisApplication.xaml.cs">
<DependentUpon>JarvisApplication.xaml</DependentUpon>
Expand Down Expand Up @@ -165,7 +166,7 @@
<Compile Include="Services\Updating\JarvisUpdateInfo.cs" />
<Compile Include="Services\Updating\UpdateChecker.cs" />
<Compile Include="ViewModels\AboutViewModel.cs" />
<Compile Include="ViewModels\Settings\GeneralSettingsViewModel.cs" />
<Compile Include="ViewModels\Settings\UpdateSettingsViewModel.cs" />
<Compile Include="ViewModels\ResultViewModel.cs" />
<Compile Include="ViewModels\SettingsViewModel.cs" />
<Compile Include="ViewModels\ShellViewModel.cs" />
Expand Down Expand Up @@ -204,7 +205,7 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Settings\GeneralSettingsView.xaml">
<Page Include="Views\Settings\UpdateSettingsView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
Expand Down
5 changes: 5 additions & 0 deletions src/Jarvis/Services/ApplicationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions src/Jarvis/Services/ServiceOrchestrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
9 changes: 8 additions & 1 deletion src/Jarvis/Services/UpdateService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool> Run(CancellationToken token)
{
#if !DEBUG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
14 changes: 12 additions & 2 deletions src/Jarvis/ViewModels/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,26 @@ namespace Jarvis.ViewModels
{
public sealed class SettingsViewModel : Conductor<ISettings>.Collection.OneActive
{
private readonly ApplicationService _application;
private readonly SettingsService _settings;

public delegate SettingsViewModel Factory();

public string ValidationMessage { get; set; }

public SettingsViewModel(IEnumerable<IQueryProvider> providers, SettingsService settings, ILifetimeScope scope)
public SettingsViewModel(
IEnumerable<IQueryProvider> 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)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<UserControl x:Class="Jarvis.Views.Settings.GeneralSettingsView"
<UserControl x:Class="Jarvis.Views.Settings.UpdateSettingsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Expand Down
6 changes: 3 additions & 3 deletions src/SharedAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

[assembly: AssemblyCompany("Spectre Systems AB")]
[assembly: AssemblyProduct("Jarvis")]
[assembly: AssemblyVersion("0.8.0")]
[assembly: AssemblyFileVersion("0.8.0")]
[assembly: AssemblyInformationalVersion("0.8.0")]
[assembly: AssemblyVersion("0.9.0")]
[assembly: AssemblyFileVersion("0.9.0")]
[assembly: AssemblyInformationalVersion("0.9.0")]
[assembly: AssemblyCopyright("Copyright (c) 2017 Spectre Systems AB")]

0 comments on commit 11dad1c

Please sign in to comment.