Skip to content

Commit

Permalink
docs: Update desktop publishing article
Browse files Browse the repository at this point in the history
(cherry picked from commit 97cfa0d)
  • Loading branch information
ebariche authored and mergify[bot] committed Oct 12, 2024
1 parent 27b82a9 commit e04f7eb
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 28 deletions.
1 change: 1 addition & 0 deletions build/cSpell.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"signalr",
"Skia",
"skiasharp",
"Snapcraft",
"Storyboarded",
"struct",
"Syncfusion",
Expand Down
128 changes: 100 additions & 28 deletions doc/articles/uno-publishing-desktop.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,122 @@
uid: uno.publishing.desktop
---

# Publishing Your App for Desktop
# Publishing Your App For Desktop

## Preparing For Publish

- [Profile your app with VS 2022](https://learn.microsoft.com/en-us/visualstudio/profiling/profiling-feature-tour?view=vs-2022)
- [Profile your app with Visual Studio](https://learn.microsoft.com/en-us/visualstudio/profiling)
- [Profile using dotnet-trace and SpeedScope](https://learn.microsoft.com/en-us/dotnet/core/diagnostics/dotnet-trace)

## Publish your app

### Using Visual Studio 2022

To publish your app with Visual Studio 2022:
## Publish Using Visual Studio 2022

- In the debugger toolbar drop-down, select the `net8.0-desktop` target framework
- Once the project has reloaded, right-click on the project and select **Publish**
- Select the appropriate target for your publication, this example will use the **Folder**, then click **Next**
- Choose an output folder for the published output, then click **Close**.
- In the opened editor, click the **Configuration** "pen" to edit the configuration
- In the opened popup, ensure that **Target Framework** is set to `net8.0-desktop`, then click **Save**
- On the top right, click the **Publish** button
- Once the build is done, the output is located in the publish folder
- Select the **Folder** target for your publication then click **Next**
- Select the **Folder** target again then **Next**
- Choose an output folder then click **Finish**
- The profile is created, you can now **Close** the dialog
- In the opened editor, click `Show all settings`
- Set **Configuration** to `Release`
- Set **Target framework** to `net8.0-desktop`
- You can set **Deployment mode** to either `Framework-dependent` or `Self-contained`
- If `Self-contained` is chosen and you're targeting Windows, **Target runtime** must match the installed .NET SDK runtime identifier
as cross-publishing self-contained WPF apps (e.g. win-x64 to win-arm64) is not supported for now.
- You can set **Target runtime**, make sure it honors the above limitation, if it applies.
- Click **Save**
- Click **Publish**

## Publish Using The CLI

On Windows/macOS/Linux, open a terminal in your `csproj` folder and run:

```shell
dotnet publish -f net8.0-desktop
```

If you wish to do a self-contained publish, run the following instead:

```shell
dotnet publish -f net8.0-desktop -r {{RID}} -p:SelfContained=true
```

Where `{{RID}}` specifies the chosen OS and Architecture (e.g. win-x64). Again when targeting Windows, cross-publishing is not supported.

Once done, you can head over to the [publishing section](xref:uno.publishing.webassembly#publishing).
### macOS App Bundles

We now support generating .app bundles on macOS machines. From the CLI run:

```shell
dotnet publish -f net8.0-desktop -p:PackageFormat=app
```

You can also do a self-contained publish with:

```shell
dotnet publish -f net8.0-desktop -r {{RID}} -p:SelfContained=true -p:PackageFormat=app
```

Where `{{RID}}` is either `osx-x64` or `osx-arm64`.

> [!NOTE]
> Code signing is planned but not supported yet.
### Using the Command Line
### Snap Packages

To build your app from the CLI, on Windows, Linux, or macOS:
We support creating .snap packages on **Ubuntu 20.04** or later.

- Open a terminal, command line, or powershell
- Navigate to your `csproj` folder
- Publish the app using:
#### Requirements

```shell
dotnet publish -f net8.0-desktop -c Release -o ./publish
```
The following must be installed and configured:

- snapd
- snaps (with `snap install`):
- core20 on Ubuntu 20.04
- core22 on Ubuntu 22.04
- core24 on Ubuntu 24.04
- multipass
- lxd
- current user must be part of the `lxd` group
- `lxd init --minimal` or similar should be run
- snapcraft

> [!NOTE]
> Docker may interfere with Lxd causing network connectivity issues, for solutions see: https://documentation.ubuntu.com/lxd/en/stable-5.0/howto/network_bridge_firewalld/#prevent-connectivity-issues-with-lxd-and-docker
#### Publishing A Snap

To publish a snap, run:

```shell
dotnet publish -f net8.0-desktop -r {{RID}} -p:SelfContained=true -p:PackageFormat=snap
```

Where `{{RID}}` is either `linux-x64` or `linux-arm64`.

We generate snap manifests in classic confinement mode and a .desktop file by default.

If you wish to customize your snap manifest, you will need to pass the following MSBuild properties:

- SnapManifest
- DesktopFile

The `.desktop` filename MUST conform to the Desktop File spec.

If you wish, you can generate a default snap manifest and desktop file by running the command above, then tweak them.

> [!NOTE]
> .NET 9 publishing and cross-publishing are not supported as of Uno 5.5, we will support .NET 9 publishing soon.
- Once the build is done, the output is located in the `./publish` folder
## Limitations

## Publishing
- NativeAOT is not supported
- R2R is not supported
- Single file publish is not supported

> [!NOTE]
> Work still in progress for publishing to some targets.
> Publishing is a work in progress
Publishing your app can be done through different means:
## Links

- [ClickOnce](https://learn.microsoft.com/visualstudio/deployment/quickstart-deploy-using-clickonce-folder?view=vs-2022) on Windows
- Using a Zip file, then running the app using `dotnet [yourapp].dll`
- [Snapcraft.yaml schema](https://snapcraft.io/docs/snapcraft-yaml-schema)
- [Desktop Entry Specification](https://specifications.freedesktop.org/desktop-entry-spec/latest)

0 comments on commit e04f7eb

Please sign in to comment.