Skip to content

Commit

Permalink
Do not reinstall webview2 per stevencohn#360 (stevencohn#361)
Browse files Browse the repository at this point in the history
Add setdevreg.ps1 to set up registry for devs
  • Loading branch information
stevencohn authored Dec 21, 2021
1 parent 61e4b81 commit de3ef84
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 8 deletions.
8 changes: 5 additions & 3 deletions OneMore.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29905.134
# Visual Studio Version 17
VisualStudioVersion = 17.0.32014.148
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OneMore", "OneMore\OneMore.csproj", "{D874E185-08FE-48C5-BADE-0FE84060C978}"
EndProject
Expand All @@ -16,6 +16,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
LICENSE = LICENSE
Reference\onenotecontrols-2016.xlsx = Reference\onenotecontrols-2016.xlsx
README.md = README.md
register-onemore.reg = register-onemore.reg
setdevreg.ps1 = setdevreg.ps1
setversion.ps1 = setversion.ps1
EndProjectSection
EndProject
Expand Down Expand Up @@ -54,7 +56,7 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D874E185-08FE-48C5-BADE-0FE84060C978}.Debug|Any CPU.ActiveCfg = Debug|x86
{D874E185-08FE-48C5-BADE-0FE84060C978}.Debug|Any CPU.ActiveCfg = Debug|x64
{D874E185-08FE-48C5-BADE-0FE84060C978}.Debug|x64.ActiveCfg = Debug|x64
{D874E185-08FE-48C5-BADE-0FE84060C978}.Debug|x64.Build.0 = Debug|x64
{D874E185-08FE-48C5-BADE-0FE84060C978}.Debug|x86.ActiveCfg = Debug|x86
Expand Down
16 changes: 14 additions & 2 deletions OneMore/Commands/Reminders/ReminderService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace River.OneMoreAddIn.Commands
{
using Microsoft.Win32;
using River.OneMoreAddIn.Models;
using System;
using System.IO;
Expand Down Expand Up @@ -135,7 +136,7 @@ await ReminderIsValid(reminder, pageID, one))
{
Send(
string.Format(
Resx.Reminder_PastDue,
Resx.Reminder_PastDue,
reminder.Due.ToShortFriendlyString(),
reminder.Subject
),
Expand Down Expand Up @@ -187,7 +188,7 @@ private async Task<bool> ReminderIsValid(Reminder reminder, string pageID, OneNo
}

reminders.Remove(orphan);
page.SetMeta(MetaNames.Reminder, serializer.EncodeContent(reminders));
page.SetMeta(MetaNames.Reminder, serializer.EncodeContent(reminders));
await one.Update(page);

return false;
Expand All @@ -196,6 +197,17 @@ private async Task<bool> ReminderIsValid(Reminder reminder, string pageID, OneNo

private void Send(string message, string args)
{
// this is for debugging; if SilentReminders value exists then only log
var key = Registry.ClassesRoot.OpenSubKey(@"River.OneMoreAddIn", false);
if (key != null)
{
if ((string)key.GetValue("SilentReminders") == "true")
{
logger.WriteLine($"Toast: {message}");
return;
}
}

/*
<toast launch="onemore://RemindCommand/{pageid};{objectid}" activationType="protocol">
<visual>
Expand Down
12 changes: 10 additions & 2 deletions OneMoreSetupActions/Deployments/EdgeWebViewDeployment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,17 @@ public override bool Install()
logger.WriteLine();
logger.WriteLine("EdgeWebViewDeployment.Install ---");

var key = Registry.LocalMachine.OpenSubKey($"{ClientKey}\\{RuntimeId}");
if (key != null)
{
logger.WriteLine("WebView2 Runtime is already installed");
CleanupChromium();
return true;
}

var bootstrap = Path.Combine(
Path.GetTempPath(),
Path.GetFileNameWithoutExtension(Path.GetRandomFileName()) + ".exe");
Path.GetTempPath(),
Path.GetFileNameWithoutExtension(Path.GetRandomFileName()) + ".exe");

if (!DownloadBootstrap(bootstrap))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public override bool Install()
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
ProtocolHandler);

var cmd = $"\"{exe}\" %1 %2 %3";
var cmd = $"\"{exe}\" %1 %2 %3 %4 %5";

key.SetValue(string.Empty, cmd);
key.Dispose();
Expand Down
Binary file added register-onemore.reg
Binary file not shown.
62 changes: 62 additions & 0 deletions setdevreg.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<#
.SYNOPSIS
Update OneMore registry keys to point to the current development directories
intead of the program files install paths
#>

param ()

Begin
{
# ProductVersion may be truncated such as "4.12" so this expands it to be "4.12.0.0"
function MakeVersion
{
param($version)
$parts = $version.Split('.')
for (($i = $parts.Length); $i -lt 4; $i++)
{
$version = "$version.0"
}
return $version
}
}
Process
{
$here = Get-Location
$guid = '{88AB88AB-CDFB-4C68-9C3A-F10B75A5BC61}'
$dll = Join-Path $here 'OneMore\bin\x86\Debug\River.OneMoreAddIn.dll'

$0 = 'Registry::HKEY_CLASSES_ROOT\onemore\shell\open\command'
if (Test-Path $0)
{
$1 = Join-Path $here 'OneMoreProtocolHandler\bin\Debug\OneMoreProtocolHandler.exe'
Write-Host "setting $0"
Set-ItemProperty $0 -Name '(Default)' -Type String -Value "$1 %1 %2 %3 %4 %5"
}

$0 = "Registry::HKEY_CLASSES_ROOT\CLSID\$guid\InprocServer32"
if (Test-Path $0)
{
Write-Host "setting $0"
Set-ItemProperty $0 -Name CodeBase -Type String -Value $dll
}

if (Test-Path $dll)
{
$pv = MaKeVersion (Get-Item $dll | % { $_.VersionInfo.ProductVersion })
$0 = "Registry::HKEY_CLASSES_ROOT\CLSID\$guid\InprocServer32\$pv"
Write-Host "testing $0"
if (Test-Path $0)
{
Write-Host "setting $0"
Set-ItemProperty $0 -Name CodeBase -Type String -Value $dll
}
}

$0 = 'Registry::HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\River.OneMoreAddIn.dll'
if (Test-Path $0)
{
Write-Host "setting $0"
Set-ItemProperty $0 -Name Path -Type String -Value $dll
}
}

0 comments on commit de3ef84

Please sign in to comment.