|
1 | | -# Getting Started: .NET |
| 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 CSharpPublish from './content/_csharp-publish.mdx'; |
| 6 | +import BuildRelease from './content/_build-release.mdx'; |
| 7 | +import Completion from './content/_completion.mdx'; |
| 8 | + |
| 9 | +# Getting Started: .NET Console / Generic C# App |
2 | 10 | <AppliesTo all /> |
3 | 11 | Get started with .NET 5+ (cross-platform) or .NET Framework. |
4 | 12 |
|
5 | | -1. Install the [Velopack NuGet Package](https://www.nuget.org/packages/velopack) in your main project: |
6 | | - ```cmd |
7 | | - dotnet add package Velopack |
8 | | - ``` |
9 | | -0. Configure your Velopack app at the beginning of `Program.Main`: |
10 | | - ```cs |
11 | | - static void Main(string[] args) |
12 | | - { |
13 | | - VelopackApp.Build().Run(); |
14 | | - // ... your other startup code below |
15 | | - } |
16 | | - ``` |
17 | | -0. Add automatic updating to your app: |
18 | | - ```cs |
19 | | - private static async Task UpdateMyApp() |
20 | | - { |
21 | | - var mgr = new UpdateManager("https://the.place/you-host/updates"); |
22 | | - |
23 | | - // check for new version |
24 | | - var newVersion = await mgr.CheckForUpdatesAsync(); |
25 | | - if (newVersion == null) |
26 | | - return; // no update available |
27 | | -
|
28 | | - // download new version |
29 | | - await mgr.DownloadUpdatesAsync(newVersion); |
30 | | - |
31 | | - // install new version and restart app |
32 | | - mgr.ApplyUpdatesAndRestart(newVersion); |
33 | | - } |
34 | | - ``` |
35 | | -0. Install the command line tool `vpk`: |
36 | | - ```cmd |
37 | | - dotnet tool update -g vpk |
38 | | - ``` |
39 | | -0. Publish dotnet and build your first Velopack release! 🎉 |
40 | | - ```batch |
41 | | - dotnet publish yourApp.csproj -c Release --self-contained -r win-x64 -o .\publish |
42 | | - vpk pack -u YourAppId -v 1.0.0 -p .\publish -e yourMainApp.exe |
43 | | - ``` |
44 | | - :::tip |
45 | | - 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). |
46 | | - 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). |
47 | | - ::: |
48 | | - |
49 | | -✅ You're Done! Your app now has auto-updates and an installer. |
50 | | -You can upload your release to your website, or use the `vpk upload` command to publish it to the destination of your choice. |
| 13 | +<InstallNuGet step={1}/> |
| 14 | + |
| 15 | +<CSharpMain step={2}/> |
| 16 | + |
| 17 | +<CSharpUpdates step={3}/> |
| 18 | + |
| 19 | +<InstallVpk step={4}/> |
| 20 | + |
| 21 | +<CSharpPublish step={5}/> |
| 22 | + |
| 23 | +<BuildRelease step={6}/> |
| 24 | + |
| 25 | +<Completion /> |
0 commit comments