Build Velopack SDK
The Velopack SDK is responsible for compiling releases and installers.
It is made up of:
- Rust binaries which are re-distributed with installed apps,
- .NET NuGet package (
Velopack), - .NET command line tool (
vpk).
In order to test the project, you need to build the Rust binaries before compiling dotnet.
Prerequisites
- .NET 8 SDK
- Rust / Cargo
dotnet tool install -g dotnet-coveragedotnet tool install -g nbgv
Debug / Test
On Windows, you need to build the Rust binaries using the windows feature before running tests. On OSX or Linux, you should run cargo build without the feature flag instead.
On Windows:
git clone https://github.com/velopack/velopack.git
cd velopack/src/bins
cargo build --features windows
cd ../../
dotnet build
dotnet test --no-build
On OSX / Linux:
git clone https://github.com/velopack/velopack.git
cd velopack/src/bins
cargo build
cd ../../
dotnet build
dotnet test --no-build
Release / Build
Creating a full production release is complex because Velopack must include native binaries for Windows, Linux, and macOS. You need to build the Rust binaries separately on each platform, then combine them on the final build machine using /p:PackRustAssets=true.
For local development, you typically only need binaries for your current OS. The simplest approach is:
On Windows:
git clone https://github.com/velopack/velopack.git
cd velopack/src/bins
cargo build --release --features windows
cd ../../
dotnet build -c Release
On OSX:
git clone https://github.com/velopack/velopack.git
cd velopack/src/bins
cargo build --release
cd ../../
dotnet build -c Release
On Linux:
git clone https://github.com/velopack/velopack.git
cd velopack/src/bins
cargo build --release
cd ../../
dotnet build -c Release
For a complete working example of building a release using local Velopack code, see the dev-scripts in the Avalonia sample.
A full cross-platform production build (combining binaries from all operating systems into one package) requires building Rust on each platform first, then running dotnet build -c Release /p:PackRustAssets=true with all platform binaries present. This workflow is handled by CI and is not practical to replicate locally. See the CI workflows for details.
Preparing Linux
If you are on Linux (tested on Ubuntu), there are additional package pre-requisites:
sudo apt install libssl-dev pkg-config build-essential
Installing dotnet and setting up the paths are a pain, I recommend using the dotnet-install.sh script.
./dotnet-install.sh -c 8.0
And then adding the following to the bottom of your .bashrc or .profile:
export DOTNET_ROOT="$HOME/.dotnet"
export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
export PATH="$PATH:$HOME/.dotnet"
export PATH="$PATH:$HOME/.dotnet/tools"
Next, install the missing dotnet tools:
dotnet tool install -g dotnet-coverage
dotnet tool install -g nbgv
You need to verify that nbgv is working on the command line (eg. nbgv -h) before continuing.
If it's not working, check that your tools installed to ~/.dotnet/tools. If you did not use the dotnet-install.sh script,
dotnet could be at a different location (eg. /usr/share/dotnet) and the paths above will need to be updated.
Once dotnet is configured, you can Install Rust, typically done with the rustup script available here
To verify that Rust is installed and working correctly, you should compile the Rust binaries in src/bins:
cargo build --target x86_64-unknown-linux-gnu --release