Getting Started: .NET Console / Generic C# App
Get started with .NET 5+ (cross-platform) or .NET Framework.
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 Main
Velopack needs to be able to bootstrap your application and handle updates. You can do this by calling VelopackApp.Build().Run()
at the start of your Main
method.
static void Main(string[] args)
{
VelopackApp.Build().Run();
// ... your other startup code below
}
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 yourApp.csproj -c Release --self-contained -r win-x64 -o .\publish
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
✅ 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.