4 2. NAPS2.Tools
Ben Olden-Cooligan edited this page 2023-09-05 15:42:47 -07:00

NAPS2 provides a set of command-line tools that builds on top of the dotnet CLI. These provides functions for building, testing, packaging, verification, etc.

How to run

Open a terminal in your NAPS2 solution directory and run the following:

Powershell

function n2 { dotnet run --project NAPS2.Tools -- $args }

Bash

alias n2="dotnet run --project NAPS2.Tools --"

Then you will be able to run commands with n2 (e.g. n2 build all).

Commands

Run n2 help for a full list of commands and n2 help <command> for all options for a particular command. Some examples:

n2 clean
n2 test
n2 build release
n2 pkg exe
n2 verify exe
n2 publish exe
n2 virus exe
n2 share
  • clean: Clear out bin/obj subfolders
  • test: Run solution tests
  • build: Builds the solution with the specified configuration (debug/exe/msi/zip/all)
  • pkg: Generates the specified package type, e.g. exe => naps2-{version}-win-x64.exe installer
  • verify: Installs/extracts the packaged file and runs NAPS2.App.Tests against it
    • Requires elevation for exe/msi as it does a real install on your local machine (and uninstalls the old NAPS2)
  • publish: Runs a series of commands: clean, test, build, pkg, verify
  • virus: Uploads a package to VirusTotal for a false positive check
  • share: Syncs local packages with a cloud folder (to help with cross-platform packaging)

Packaging

One of the most useful commands is n2 pkg. Here are examples to create each of NAPS2's release files individually:

# Windows
n2 pkg exe
n2 pkg msi -p win32
n2 pkg msi -p win64
n2 pkg zip

# Mac
n2 pkg pkg -p mac
n2 pkg pkg -p macintel
n2 pkg pkg -p macarm

# Linux
n2 pkg deb -p linux
n2 pkg deb -p linuxarm
n2 pkg rpm -p linux
n2 pkg rpm -p linuxarm
n2 pkg flatpak -p linux
n2 pkg flatpak -p linuxarm