Skip to content

Commit ab8bb61

Browse files
committed
Adding Getting Started with WPF instructions
1 parent 69e2728 commit ab8bb61

File tree

9 files changed

+190
-2
lines changed

9 files changed

+190
-2
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<FancyStep step={props.step}>
2+
<details>
3+
<summary>
4+
<strong>Build Velopack release!</strong>
5+
</summary>
6+
7+
You are now ready to build a Velopack release for your application.
8+
9+
See the [CLI reference](/reference/cli/) for more details on the available options.
10+
11+
```cmd
12+
vpk pack -u YourAppId -v 1.0.0 -p .\publish -e yourMainApp.exe
13+
```
14+
</details>
15+
</FancyStep>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
✅ You're Done! Your app now has auto-updates and an installer.
2+
You can upload your release to your website, or use the `vpk upload` command to publish it to the destination of your choice.
3+
4+
You can also check out our [Sample Apps](/category/sample-apps) to see completed examples that leverage Velopack.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<FancyStep step={props.step}>
2+
<details>
3+
<summary>
4+
<strong>Configure your Velopack app at the beginning of Main</strong>
5+
</summary>
6+
7+
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.
8+
9+
```csharp
10+
static void Main(string[] args)
11+
{
12+
VelopackApp.Build().Run();
13+
// ... your other startup code below
14+
}
15+
```
16+
</details>
17+
</FancyStep>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<FancyStep step={props.step}>
2+
<details>
3+
<summary>
4+
<strong>Add update check within your app</strong>
5+
</summary>
6+
7+
Velopack provides a simple way to check for updates and apply them.
8+
The following show how to implement a basic update check within your application.
9+
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.
11+
12+
```csharp
13+
private static async Task UpdateMyApp()
14+
{
15+
var mgr = new UpdateManager("https://the.place/you-host/updates");
16+
17+
// check for new version
18+
var newVersion = await mgr.CheckForUpdatesAsync();
19+
if (newVersion == null)
20+
return; // no update available
21+
22+
// download new version
23+
await mgr.DownloadUpdatesAsync(newVersion);
24+
25+
// install new version and restart app
26+
mgr.ApplyUpdatesAndRestart(newVersion);
27+
}
28+
```
29+
</details>
30+
</FancyStep>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<FancyStep step={props.step}>
2+
<details>
3+
<summary>
4+
<strong>Install Velopack NuGet package</strong>
5+
</summary>
6+
7+
Install the <a href="https://www.nuget.org/packages/velopack" target="_blank">Velopack NuGet Package</a> in your main project.
8+
This is the project that will contain the Main method of your application.
9+
</details>
10+
</FancyStep>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<FancyStep step={props.step}>
2+
<details>
3+
<summary>
4+
<strong>Install `vpk`</strong>
5+
</summary>
6+
7+
Velopack uses a command line tool called `vpk` to package and publish releases.
8+
It is distributed as a [.NET global tool](https://learn.microsoft.com/dotnet/core/tools/global-tools). Though Velopack can be used with app from [various languages](/#language-support), the .NET is required to install and run `vpk`.
9+
You can install the .NET SDK from the [.NET download page](https://dotnet.microsoft.com/download/dotnet).
10+
11+
Once .NET is installed, you can install `vpk` by running:
12+
```cmd
13+
dotnet tool install -g vpk
14+
```
15+
</details>
16+
</FancyStep>

docs/getting-started/csharp.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Getting Started: .NET
22
<AppliesTo all />
3-
Get started with .NET 5+ (cross-platform) or .Net Framework.
3+
Get started with .NET 5+ (cross-platform) or .NET Framework.
44

55
1. Install the [Velopack NuGet Package](https://www.nuget.org/packages/velopack) in your main project:
66
```cmd

docs/getting-started/wpf.mdx

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import InstallNuGet from './content/_install-nuget.mdx';
2+
import CSharpMain from './content/_csharp-main.mdx';
3+
import CSharpUpdates from './content/_csharp-updates.mdx';
4+
import InstallVpk from './content/_install_vpk.mdx';
5+
import BuildRelease from './content/_build_release.mdx';
6+
import Completion from './content/_completion.mdx';
7+
8+
# Getting Started: C# / WPF
9+
<AppliesTo win />
10+
Get started with .NET 5+ (cross-platform) or .NET Framework.
11+
12+
<InstallNuGet step={1}/>
13+
14+
<FancyStep step={2}>
15+
<details>
16+
<summary>
17+
<strong>Create a Main method</strong>
18+
</summary>
19+
20+
Though it is possible to simply put the Velopack bootstrap call within `App.xaml.cs`, we recommend creating a custom `Main` method to avoid any WPF overhead when applying updates.
21+
22+
First, change the Build Actio of `App.xaml` to `Page` (right-click the file in Solution Explorer, select Properties, and change the Build Action).
23+
The project file should contain the following lines:
24+
```xml
25+
<ItemGroup>
26+
<ApplicationDefinition Remove="App.xaml"/>
27+
<Page Include="App.xaml"/>
28+
</ItemGroup>
29+
```
30+
31+
While editing the project file, change the StartupObject to point to your `App` class.
32+
Add the following PropertyGroup to your `.csproj` file:
33+
```xml
34+
<PropertyGroup>
35+
<StartupObject>YourNamespace.App</StartupObject>
36+
</PropertyGroup>
37+
```
38+
39+
Add a `Main` method to your `App.xaml.cs` file. It should look similar to this:
40+
```csharp
41+
public partial class App : Application
42+
{
43+
[STAThread]
44+
private static void Main(string[] args)
45+
{
46+
App app = new();
47+
app.InitializeComponent();
48+
app.Run();
49+
}
50+
// The rest of your App.xaml.cs code goes here
51+
}
52+
```
53+
54+
Verify the changes by ensuring your app still starts correctly.
55+
</details>
56+
</FancyStep>
57+
58+
<CSharpMain step={3}/>
59+
60+
<CSharpUpdates step={4}/>
61+
62+
<InstallVpk step={5}/>
63+
64+
<FancyStep step={6}>
65+
<details>
66+
<summary>
67+
<strong>Publish App</strong>
68+
</summary>
69+
70+
Before building a Velopack release, you must first build your application and publish it to a directory.
71+
72+
For simplicity, we recommend publishing it as a [self-contained application](https://learn.microsoft.com/en-us/dotnet/core/deploying/#publish-self-contained).
73+
74+
```batch
75+
dotnet publish yourApp.csproj -c Release --self-contained -r win-x64 -o .\publish
76+
```
77+
:::tip
78+
Starting with .NET 7, the `-o`/`--output` option [can no longer be used with a solution file](https://learn.microsoft.com/en-us/dotnet/core/compatibility/sdk/7.0/solution-level-output-no-longer-valid?WT.mc_id=DT-MVP-5003472).
79+
:::
80+
81+
:::tip
82+
Starting with .NET 8 and later, the `dotnet publish` command defaults to the Release configuration, so you can omit the `-c Release` option.
83+
For more details see https://learn.microsoft.com/en-us/dotnet/core/compatibility/sdk/8.0/dotnet-publish-config.
84+
:::
85+
86+
:::tip
87+
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](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-publish?WT.mc_id=DT-MVP-5003472#arguments).
88+
:::
89+
90+
</details>
91+
</FancyStep>
92+
93+
<BuildRelease step={7}/>
94+
95+
<Completion />

sidebars.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ const sidebars: SidebarsConfig = {
4141
"index",
4242
{
4343
type: 'category',
44-
label: 'Quick Start',
44+
label: 'Getting Started',
4545
items: [
4646
doc("getting-started/csharp", "C# / .NET"),
47+
doc("getting-started/wpf", "C# / WPF"),
4748
doc("getting-started/cpp", "C / C++"),
4849
doc("getting-started/electron", "JS / Electron"),
4950
doc("getting-started/rust", "Rust"),

0 commit comments

Comments
 (0)