Skip to content

Commit 91e913b

Browse files
committed
Updating C++ getting started
Adds a new getting started guide for C/C++ applications. This guide walks developers through the process of integrating Velopack into their C/C++ projects for auto-updates and installers.
1 parent 96db835 commit 91e913b

6 files changed

Lines changed: 99 additions & 57 deletions

File tree

File renamed without changes.

docs/getting-started/content/_csharp-main.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<FancyStep step={props.step}>
22
<details>
33
<summary>
4-
<strong>Configure your Velopack app at the beginning of Main</strong>
4+
<strong>Configure Velopack at the beginning of Main</strong>
55
</summary>
66

77
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.

docs/getting-started/content/_csharp-updates.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
Velopack provides a simple way to check for updates and apply them.
88
The following show how to implement a basic update check within your application.
99

10-
You can also split up the various methods to allow your users control of when to check for updates, download them, or apply them.
10+
You can also split up the various methods to allow your users to control when to check for updates, download them, or apply them.
1111

1212
```csharp
1313
private static async Task UpdateMyApp()
File renamed without changes.

docs/getting-started/cpp.mdx

Lines changed: 95 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1+
import InstallVpk from './content/_install-vpk.mdx';
2+
import BuildRelease from './content/_build-release.mdx';
3+
import Completion from './content/_completion.mdx';
4+
5+
16
# Getting Started: C / C++
7+
28
<AppliesTo all />
39
Get started with our cross-platform C / C++ library.
410

@@ -11,62 +17,98 @@ All the strings (eg. `char*` or `std::string`) are expected to be UTF-8 encoded.
1117
On Windows, you may need to convert `wchar_t*` and `std::wstring` to UTF-8 before passing it to the library.
1218
:::
1319

14-
1. Download the latest `velopack_libc_{version}.zip` from [GitHub Releases](https://github.com/velopack/velopack/releases) and include it into your project.
15-
16-
0. Add the `include` directory to your include path, and add the appropriate binary from `lib` to your linker options.
17-
18-
0. Add `VelopackApp` to your entry point (eg. `main()` or `wmain()`) as early as possible, ideally the first statement to run:
19-
```cpp
20-
#include "Velopack.h"
21-
22-
wmain(int argc**, wchar_t *argv[ ], wchar_t *envp[ ])
23-
{
24-
// This should run as early as possible in the main method.
25-
// Velopack may exit / restart the app at this point.
26-
// See VelopackApp class for more options/configuration.
27-
Velopack::VelopackApp::Build().Run();
28-
29-
// ... your other startup code here
30-
}
31-
```
32-
33-
0. Add auto-updates somewhere to your app:
34-
```cpp
35-
#include "Velopack.h"
36-
37-
static void update_app()
38-
{
39-
Velopack::UpdateManager manager("https://the.place/you-host/updates");
40-
41-
auto updInfo = manager.CheckForUpdates();
42-
if (!updInfo.has_value()) {
43-
return; // no updates available
20+
<FancyStep step={1}>
21+
<details>
22+
<summary>
23+
<strong>Download Velopack C/C++ library</strong>
24+
</summary>
25+
26+
Download the latest `velopack_libc_{version}.zip` from [GitHub Releases](https://github.com/velopack/velopack/releases) and include it into your project.
27+
Extract the contents of the zip file to a directory you can reference in your project.
28+
</details>
29+
</FancyStep>
30+
31+
<FancyStep step={2}>
32+
<details>
33+
<summary>
34+
<strong>Include Velopack in your project</strong>
35+
</summary>
36+
37+
Add the `include` directory from the extracted content to your include path, and add the appropriate binary from `lib` to your linker options.
38+
You will find both a `lib` and `lib-static` directories in the extracted contents.
39+
</details>
40+
</FancyStep>
41+
42+
43+
<FancyStep step={3}>
44+
<details>
45+
<summary>
46+
<strong>Configure Velopack at the beginning of Main</strong>
47+
</summary>
48+
49+
Add `VelopackApp` to your entry point (eg. `main()` or `wmain()`) as early as possible, ideally the first statement to run:
50+
```cpp
51+
#include "Velopack.h"
52+
53+
wmain(int argc**, wchar_t *argv[ ], wchar_t *envp[ ])
54+
{
55+
// This should run as early as possible in the main method.
56+
// Velopack may exit / restart the app at this point.
57+
// See VelopackApp class for more options/configuration.
58+
Velopack::VelopackApp::Build().Run();
59+
60+
// ... your other startup code here
4461
}
62+
```
63+
</details>
64+
</FancyStep>
65+
66+
<FancyStep step={4}>
67+
<details>
68+
<summary>
69+
<strong>Add update check within your app</strong>
70+
</summary>
71+
72+
Velopack provides a simple way to check for updates and apply them.
73+
The following show how to implement a basic update check within your application.
74+
75+
You can also split up the various methods to allow your users to control when to check for updates, download them, or apply them.
76+
77+
```cpp
78+
#include "Velopack.h"
79+
80+
static void update_app()
81+
{
82+
Velopack::UpdateManager manager("https://the.place/you-host/updates");
83+
84+
auto updInfo = manager.CheckForUpdates();
85+
if (!updInfo.has_value()) {
86+
return; // no updates available
87+
}
88+
89+
// download the update, optionally providing progress callbacks
90+
manager.DownloadUpdates(updInfo.value());
91+
92+
// prepare the Updater in a new process, and wait 60 seconds for this process to exit
93+
manager.WaitExitThenApplyUpdate(updInfo.value());
94+
exit(0); // exit the app to apply the update
95+
}
96+
```
97+
</details>
98+
</FancyStep>
4599

46-
// download the update, optionally providing progress callbacks
47-
manager.DownloadUpdates(updInfo.value());
48-
49-
// prepare the Updater in a new process, and wait 60 seconds for this process to exit
50-
manager.WaitExitThenApplyUpdate(updInfo.value());
51-
exit(0); // exit the app to apply the update
52-
}
53-
```
54-
55-
0. Install the `vpk` command line tool:
56-
```sh
57-
dotnet tool update -g vpk
58-
```
59-
:::tip
60-
***You must have the .NET Core SDK 8 installed to use and update `vpk`***
61-
:::
100+
<InstallVpk step={5}/>
62101

102+
<FancyStep step={6}>
103+
<details>
104+
<summary>
105+
<strong>Compile your app</strong>
106+
</summary>
63107

64-
0. Compile your app to a program using your usual compiler (eg. msvc, cmake, gcc, etc)
108+
Compile your app to a program using your usual compiler (eg. msvc, cmake, gcc, etc)
109+
</details>
110+
</FancyStep>
65111

66-
0. Package your Velopack release / installers:
67-
```sh
68-
vpk pack -u MyAppUniqueId -v 1.0.0 -p /myBuildDir -e myexename.exe
69-
```
112+
<BuildRelease step={7}/>
70113

71-
✅ You're Done! Your app now has auto-updates and an installer.
72-
You can upload your release to your website, or use the `vpk upload` command to publish it to the destination of your choice.
114+
<Completion />

docs/getting-started/wpf.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import InstallNuGet from './content/_install-nuget.mdx';
22
import CSharpMain from './content/_csharp-main.mdx';
33
import CSharpUpdates from './content/_csharp-updates.mdx';
4-
import InstallVpk from './content/_install_vpk.mdx';
5-
import BuildRelease from './content/_build_release.mdx';
4+
import InstallVpk from './content/_install-vpk.mdx';
5+
import BuildRelease from './content/_build-release.mdx';
66
import Completion from './content/_completion.mdx';
77
import Admonition from '@theme/Admonition';
88

0 commit comments

Comments
 (0)