Scripts

Sunday, March 5, 2023

9:57 AM

While developing OneMore, I've found it useful to maintain a small set of scripts to automate common tasks and to create repeatable environments and configurations.

 

build.ps1

Its usage is described in detail here but its general purpose is to automate building the installer for different architectures. The OneMore solution is set to build x64 by default. This script temporarily modifies the solution to build x86, builds, and then resets the configuration back to x64.

 

  • .\build.ps1 86 - builds just the x86 installer
  • .\build.ps1 64 - builds just the x64 installer; the default if no arguments are provided
  • .\build.ps1 -both - builds both the x86 and the x64 installers
  • .\build.ps1 -fast - builds just the OneMore and OneMoreProtocolHandler projects, without the installer
  • .\build.ps1 -prep - prepares your workstation to build using this script as described here

 

install-vsix.ps1

Installs the Visual Studio Installer Projects extensions. Currently set up for VS2022.

 

iq.ps1

This is the installation qualification script. It simply reads and reports the configuration from the System Registry and identifies any issues. Typical output of a correctly configured system looks like this:

 

 

PS C:\Github\OneMore> .\iq.ps1

 

Versions...

OK Office version is 16.0

OK OneNote version is 15.0 (64-bit)

 

AppID...

OK Registry::HKEY_CLASSES_ROOT\AppID\{88AB88AB-CDFB-4C68-9C3A-F10B75A5BC61}

 

Root...

OK Registry::HKEY_CLASSES_ROOT\onemore

 

Shell...

OK Registry::HKEY_CLASSES_ROOT\onemore\shell\open\command

= "C:\Program Files\River\OneMoreAddIn\OneMoreProtocolHandler.exe" %1 %2 %3 %4 %5

 

AddIn...

OK Registry::HKEY_CLASSES_ROOT\River.OneMoreAddIn

OK Registry::HKEY_CLASSES_ROOT\River.OneMoreAddIn.1

 

CLSID...

OK Registry::HKEY_CLASSES_ROOT\CLSID\{88AB88AB-CDFB-4C68-9C3A-F10B75A5BC61}

OK Registry::HKEY_CLASSES_ROOT\CLSID\{88AB88AB-CDFB-4C68-9C3A-F10B75A5BC61}\InprocServer32

OK Registry::HKEY_CLASSES_ROOT\CLSID\{88AB88AB-CDFB-4C68-9C3A-F10B75A5BC61}\InprocServer32\5.8.1.0

= Assembly = River.OneMoreAddIn, Version=5.7.2.0, Culture=neutral, PublicKeyToken=null
= CodeBase = C:\Github\OneMore\OneMore\bin\x86\Debug\River.OneMoreAddIn.dll
= RuntimeVersion = v4.0.30319
= Class = River.OneMoreAddIn.AddIn

OK Registry::HKEY_CLASSES_ROOT\CLSID\{88AB88AB-CDFB-4C68-9C3A-F10B75A5BC61}\ProgID

OK Registry::HKEY_CLASSES_ROOT\CLSID\{88AB88AB-CDFB-4C68-9C3A-F10B75A5BC61}\Programmable

OK Registry::HKEY_CLASSES_ROOT\CLSID\{88AB88AB-CDFB-4C68-9C3A-F10B75A5BC61}\TypeLib

OK Registry::HKEY_CLASSES_ROOT\CLSID\{88AB88AB-CDFB-4C68-9C3A-F10B75A5BC61}\VersionIndependentProgID

 

User...

OK Registry::HKEY_CURRENT_USER\SOFTWARE\Classes\AppID\{88AB88AB-CDFB-4C68-9C3A-F10B75A5BC61}

OK Registry::HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\OneNote\AddIns\River.OneMoreAddIn

OK Registry::HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\River.OneMoreAddIn.dll

= C:\Github\OneMore\OneMore\bin\x86\Debug\River.OneMoreAddIn.dll

OK Registry::HKEY_CURRENT_USER\SOFTWARE\Policies\Microsoft\Office\16.0\Common\Security\Trusted Protocols\All Applications\onemore:

 

WebView2...

OK Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}

OK location = C:\Program Files (x86)\Microsoft\EdgeWebView\Application

= version = 110.0.1587.63
= location = C:\Program Files (x86)\Microsoft\EdgeWebView\Application

 

 

setregistry.ps1

This is an easy way of configuring the COM registration paths in the Registry to point to your Visual Studio output folders rather than the installation path.

 

  1. You must first install OneMore as you normally would to create all the necessary Registry entries.
  2. Clone the OneMore repo to your local machine
  3. Run the .\Build.ps1 -Fast script to create the DLLs that setregistry needs to discover
  4. Run the script from the root folder of the repo

 

PS C:\Github\OneMore> .\setregistry.ps1

 

  1. Run this script to redirect the COM Registry settings

 

When you rebuild OneMore and run OneNote, it will run the add-in out of your local repo rather the installed location.

 

You can also reset the Registry configuration to point to the install path using the -Reset argument

 

PS C:\Github\OneMore> .\setregistry.ps1 -Reset

 

 

PS C:\Github\OneMore> .\setregistry.ps1

 

OK OneNote version is 15.0 (64-bit), Office version is 16.0
OK OneNote found at C:\Program Files\Microsoft Office\Root\Office16\ONENOTE.EXE
OK OneMore found at C:\Github\OneMore\OneMore\bin\x86\Debug\River.OneMoreAddIn.dll
OK OneMore version is 5.8.4.0

 

Root...

OK Registry::HKEY_CLASSES_ROOT\River.OneMoreAddIn
OK Registry::HKEY_CLASSES_ROOT\River.OneMoreAddIn\CLSID
OK Registry::HKEY_CLASSES_ROOT\River.OneMoreAddIn\CurVer
OK Registry::HKEY_CLASSES_ROOT\River.OneMoreAddIn.1
OK Registry::HKEY_CLASSES_ROOT\River.OneMoreAddIn.1\CLSID

 

AppID...

OK Registry::HKEY_CLASSES_ROOT\AppID\{88AB88AB-CDFB-4C68-9C3A-F10B75A5BC61}

 

Protocol handler...

OK Registry::HKEY_CLASSES_ROOT\onemore

OK Registry::HKEY_CLASSES_ROOT\onemore\shell\open\command

= "C:\Github\OneMore\OneMoreProtocolHandler\bin\Debug\OneMoreProtocolHandler.exe" %1 %2 %3 %4 %5

 

CLSID...

OK Registry::HKEY_CLASSES_ROOT\CLSID\{88AB88AB-CDFB-4C68-9C3A-F10B75A5BC61}
OK Registry::HKEY_CLASSES_ROOT\CLSID\Implemented Categories\{62C8FE65-4EBB-45E7-B440-6E39B2CDBF29}
OK Registry::HKEY_CLASSES_ROOT\CLSID\{88AB88AB-CDFB-4C68-9C3A-F10B75A5BC61}\InprocServer32
OK Registry::HKEY_CLASSES_ROOT\CLSID\{88AB88AB-CDFB-4C68-9C3A-F10B75A5BC61}\InprocServer32\5.8.4.0

= C:\Github\OneMore\OneMore\bin\x86\Debug\River.OneMoreAddIn.dll

OK Registry::HKEY_CLASSES_ROOT\CLSID\{88AB88AB-CDFB-4C68-9C3A-F10B75A5BC61}\ProgID
OK Registry::HKEY_CLASSES_ROOT\CLSID\{88AB88AB-CDFB-4C68-9C3A-F10B75A5BC61}\Programmable
OK Registry::HKEY_CLASSES_ROOT\CLSID\{88AB88AB-CDFB-4C68-9C3A-F10B75A5BC61}\TypeLib
OK Registry::HKEY_CLASSES_ROOT\CLSID\{88AB88AB-CDFB-4C68-9C3A-F10B75A5BC61}\VersionIndependentProgID

 

User...

OK Registry::HKEY_CURRENT_USER\SOFTWARE\Classes\AppID\{88AB88AB-CDFB-4C68-9C3A-F10B75A5BC61}
OK Registry::HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\OneNote\AddIns\River.OneMoreAddIn
OK Registry::HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\River.OneMoreAddIn.dll

= C:\Github\OneMore\OneMore\bin\x86\Debug\River.OneMoreAddIn.dll

OK Registry::HKEY_CURRENT_USER\SOFTWARE\Policies\Microsoft\Office\16.0\Common\Security\Trusted Protocols\All Applications\onemore:

 

 

setversion.ps1

There are a number of places that need to be touched every time OneMore is versioned to be released. This script automates that task by updating each of them with a specified version string. The usage is

 

PS C:\Github\OneMore> .\setversion.ps1 5.8.1

 

Specify a complete semantic version of the form major.minor.patch

 

This script touches these files

 

  • .\OneMore\Properties\AssemblyInfo.cs
  • .\OneMoreCalendar\Properties\AssemblyInfo.cs
  • .\OneMoreProtocolHandler\Properties\AssemblyInfo.cs
  • .\OneMoreSetupActions\Properties\AssemblyInfo.cs
  • .\OneMoreSetup\OneMoreSetup.vdproj

 

stop.ps1

In the event that OneMore or OneNote becomes unresponsive, or you think you've shutdown OneNote but the dllhost COM suggogate process remains, use this script to forcefully terminate these processes.

 

This script specifically targets only the OneMore COM suggogate process and the ONENOTE.exe process. No other processes will be affected.

 

update-sdk.ps1

Patches the OneMore.csproj file with your machine's path to the .NET Framework System.Runtime.WindowsRuntime assembly and the path and version of the Windows SDK Windows.winmd file. Read more about this on the developer's Getting Started page.

 

If no changes are required, you'll see something like this

 

 

PS C:\Github\OneMore> .\update-sdk.ps1

 

Updating Windows SDK 10.0.22621.0 (C:\Program Files (x86)\Windows Kits\10\)

 

OK NET Framework path is already correct

OK Windows SDK is already correct

OK no changes required

 

 

 

#omwiki #omdeveloper

 

© 2020 Steven M Cohn. All rights reserved.

Please consider a sponsorship or one-time donation to support ongoing development

 

Created with OneNote.