Getting Started: Uno Platform
The Uno Platform provies .NET developers with an open-source platform for building single codebase native mobile, web, desktop and embedded apps quickly. Velopack offers a cross platform solution for deploying the desktop (Windows, macOS, and Linux) versions of those applications. For publishing other platforms see Uno Platform's documentation.
Create Uno Project
Start by creating a new Uno application following Uno Platform's Getting Started guide.
Install Velopack NuGet package
Install the Velopack NuGet Package in your main project. This is the project that will contain the Main method of your application.
Configure Velopack at the beginning of App.xaml.cs
Add the following code to your App.xaml.cs
file:
public App()
{
// It's important to Run() the VelopackApp as early as possible in app startup.
VelopackApp.Build()
.WithFirstRun((v) => { /* Your first run code here */ })
.Run();
this.InitializeComponent();
}
Add update check within your app
Velopack provides a simple way to check for updates and apply them. The following show how to implement a basic update check within your application.
You can also split up the various methods to allow your users to control when to check for updates, download them, or apply them.
private static async Task UpdateMyApp()
{
var mgr = new UpdateManager("https://the.place/you-host/updates");
// check for new version
var newVersion = await mgr.CheckForUpdatesAsync();
if (newVersion == null)
return; // no update available
// download new version
await mgr.DownloadUpdatesAsync(newVersion);
// install new version and restart app
mgr.ApplyUpdatesAndRestart(newVersion);
}
Publish App
Before building a Velopack release, you must first build your application and publish it to a directory.
For simplicity, we recommend publishing it as a self-contained application.
dotnet publish -f net8.0-desktop -p:Version=1.0.0 -o .\publish
This will create the artifacts to be installed inside of the publish
directory. If you are targeting multiple platforms this process will need to be repeated for each of those platforms replacing the -f
option with the appropriate target framework moniker (TFM) for each platform, such as net8.0-windows
or net8.0-maccatalyst
.
For additional information on publishing your Uno application see the Uno publishing guides
Starting with .NET 7, the -o
/--output
option can no longer be used with a solution file.
Starting with .NET 8 and later, the dotnet publish
command defaults to the Release configuration, so you can omit the -c Release
option.
For more details see https://learn.microsoft.com/en-us/dotnet/core/compatibility/sdk/8.0/dotnet-publish-config.
If you execute the dotnet publish command from within the same directory as the .csproj file, you can omit the project argument. You can find more details on the dotnet publish documentation.
Install vpk
Velopack uses a command line tool called vpk
to package and publish releases.
It is distributed as a .NET global tool. Though Velopack can be used with app from various languages, the .NET is required to install and run vpk
.
You can install the .NET SDK from the .NET download page.
Once .NET is installed, you can install vpk
by running:
dotnet tool install -g vpk
Build Velopack release!
You are now ready to build a Velopack release for your application.
The --packId
can be any unique application identifier that you wish to use. Because this must be unique across all applications,
we recommend including your company name: <CompanyName>.<AppName>
.
The --mainExe
option is only required if your executable name is different than the --packId
of your application.
See the CLI reference for more details on the available options.
vpk pack --packId YourAppId --packVersion 1.0.0 --packDir .\publish --mainExe yourMainApp.exe
vpk
will produce the a warning saying that the VelopackApp.Run()
was not found in the entry point of your application. This is expected, and the warning can be safely ignored for this type of application.✅ You're Done! Your app now has auto-updates and an installer.
You can upload your release to your website, or use the vpk upload
command to publish it to the destination of your choice.
You can also check out our Sample Apps to see completed examples that leverage Velopack.