Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add windows publishing steps #16678

Merged
merged 15 commits into from
May 28, 2024
Merged
3 changes: 3 additions & 0 deletions build/cSpell.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"msbuild",
"MVUX",
"MVVM",
"MSIX",
"NETSDK",
"netstandard",
"neumorphic",
Expand Down Expand Up @@ -151,8 +152,10 @@
"odel",
"pdate",
"progressring",
"pwsh",
"Ronica",
"Serilog",
"Sideloading",
"Singh",
"slnf",
"startscreen",
Expand Down
12 changes: 12 additions & 0 deletions doc/articles/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,18 @@
topicHref: guides/silverlight-migration/silverlight-migration-landing.md
href: guides/silverlight-migration/toc.yml

- name: Publishing
items:
- name: Overview
href: xref:uno.publishing.overview
- name: Publishing for Windows
topicHref: xref:uno.publishing.windows
items:
- name: Build Packaged Unsigned Apps
href: xref:uno.publishing.windows.sideload.packaged.unsigned
- name: Build Packaged Signed Apps
href: xref:uno.publishing.windows.sideload.packaged.signed

- name: Performance
items:
- name: Improving Build Times
Expand Down
18 changes: 18 additions & 0 deletions doc/articles/uno-publishing-overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
uid: uno.publishing.overview
---

# Publishing Your App

## Preparing

- [Configure the IL Linker](xref:uno.articles.features.illinker)
- [Improve Performance](xref:Uno.Development.Performance)

## Packaging

- [Packaging for Windows](xref:uno.publishing.windows)

## Deploying

_To be documented._
87 changes: 87 additions & 0 deletions doc/articles/uno-publishing-windows-packaged-signed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
---
uid: uno.publishing.windows.sideload.packaged.signed
---

# Build a signed packaged app

This guide will show how to create an signed packaged app using Windows App SDK.
jeromelaban marked this conversation as resolved.
Show resolved Hide resolved

> [!IMPORTANT]
> Building your app requires using the msbuild command (`dotnet build` is not compatible as of WinAppSDK 1.5).

## Package signed the app

This guide uses a self-signed certificate.

To package your app:

- Create a self-signed certificate:
- Open the solution in Visual Studio 2022
- Ensure that the active debugging target framework is `net8.0-windows10.xxx` (Please upvote [this Visual Studio issue](https://developercommunity.visualstudio.com/t/Double-clicking-on-a-PackageAppxmanifes/10658683))
- Double-click on the `Package.appxmanifest` file
- Navigate to the `Packaging` tab
- Click the **Choose certificate** button
- Click the **Create** button, then set a **publisher common name**, then OK. Do not set a password.
- Close the **Choose a Certificate** window by clicking OK.
- Click the **Save file** button in the Visual Studio toolbar
- Navigate to the folder of the app's `.csproj` (Building at the solution level is not supported)
- Build the app on the command line with the following command:

```shell
msbuild /r /p:TargetFramework=net8.0-windows10.0.19041 /p:Configuration=Release /p:Platform=x64 /p:GenerateAppxPackageOnBuild=true /p:AppxBundle=Never /p:UapAppxPackageBuildMode=Sideloading /p:AppxPackageDir="C:/temp/output/" /p:AppxPackageSigningEnabled=true
```

In order to build for additional platforms, change the `Platform` parameter to `x86` or `arm64` to create additional MSIX files.

> [!IMPORTANT]
> Single package msix bundling is [not yet supported from msbuild the command line](https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/single-project-msix?tabs=csharp#automate-building-and-packaging-your-single-project-msix-app).

## Considerations for solutions with class library projects

If your app references multiple library projects projects, you will need to split the above build command in two parts, one to restore NuGet packages, and the other one to create the package.
jeromelaban marked this conversation as resolved.
Show resolved Hide resolved

To build your solution:

- Add the following to your app's csproj:

```xml
<PropertyGroup Condition=" '$(PublishSignedPackage)' == 'true' ">
<GenerateAppxPackageOnBuild>true</GenerateAppxPackageOnBuild>
<AppxBundle>Never</AppxBundle>
<UapAppxPackageBuildMode>Sideloading</UapAppxPackageBuildMode>
<AppxPackageSigningEnabled>true</AppxPackageSigningEnabled>
</PropertyGroup>
```

- Run this command to restore the nuget packages:
jeromelaban marked this conversation as resolved.
Show resolved Hide resolved

```shell
msbuild /r /t:Restore /p:Configuration=Release
```

- Then run this command:

```shell
msbuild /p:TargetFramework=net8.0-windows10.0.19041 /p:Configuration=Release /p:Platform=x64 /p:PublishSignedPackage=true /p:AppxPackageDir="C:/temp/output/"
```

Notice that this command does not contain the `/r`.

## Install the signed app

To install the app:

- Install the certificate on the machine:
- In the file explorer, right-click on the `.msix` file, then **Show More Options** on Windows 11, then **Properties**
- Open the **Digital signatures** tab
- Click on your certificate then **Details**
- Click the **View Certificate** button
- Click the **Install Certificate** button
- Select **Local Machine** then **Next**
- Click **Place all certificates in the following store** then **Browse**
- Select **Trusted People** then **OK**
- Click **Next**, then **Finish**
- Close all the opened properties windows.
- Install the `.msix` by double-clicking on it

The app will start automatically once installed.
77 changes: 77 additions & 0 deletions doc/articles/uno-publishing-windows-packaged-unsigned.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
uid: uno.publishing.windows.sideload.packaged.unsigned
---

# Build an unsigned packaged app

This guide will show how to create an unsigned packaged app using Windows App SDK.

> [!IMPORTANT]
> Building your app requires using the msbuild command (`dotnet build` is not compatible as of WinAppSDK 1.5).

## Package the unsigned app

Packaging the app without a code signature allows for installing the app on a machine without having to install the signer's certificate. This portion of the guide is derived from the [official Windows App SDK documentation](https://learn.microsoft.com/en-us/windows/msix/package/unsigned-package).

To package your app:

- Update the `Package.appxmanifest` file with the following `Identity` node to include the following `OID`:

```xml
<Identity Name="MyApp"
Publisher="CN=AppModelSamples, OID.2.25.311729368913984317654407730594956997722=1"
Version="1.0.0.0" />
```

- Navigate to the folder of the app's `.csproj` (Building at the solution level is not supported)
- Build your app using the following command:

```pwsh
msbuild /r /p:TargetFramework=net8.0-windows10.0.19041 /p:Configuration=Release /p:Platform=x64 /p:GenerateAppxPackageOnBuild=true /p:AppxBundle=Never /p:UapAppxPackageBuildMode=Sideloading /p:AppxPackageDir="C:/temp/output/" /p:AppxPackageSigningEnabled=false
```

In order to build for additional platforms, change the `Platform` parameter to `x86` or `arm64` to create additional MSIX files.

## Considerations for solutions with class library projects

If your app references multiple library projects projects, you will need to split the above build command in two parts, one to restore NuGet packages, and the other one to create the package.
jeromelaban marked this conversation as resolved.
Show resolved Hide resolved

To build your solution:

- Add the following to your app's csproj:

```xml
<PropertyGroup Condition=" '$(PublishUnsignedPackage)' == 'true' ">
<GenerateAppxPackageOnBuild>true</GenerateAppxPackageOnBuild>
<AppxBundle>Never</AppxBundle>
<UapAppxPackageBuildMode>Sideloading</UapAppxPackageBuildMode>
<AppxPackageSigningEnabled>false</AppxPackageSigningEnabled>
</PropertyGroup>
```

- Run this command to restore the nuget packages:
jeromelaban marked this conversation as resolved.
Show resolved Hide resolved

```pwsh
msbuild /r /t:Restore /p:Configuration=Release
```

- Then run this command:

```pwsh
msbuild /p:TargetFramework=net8.0-windows10.0.19041 /p:Configuration=Release /p:Platform=x64 /p:PublishUnsignedPackage=true /p:AppxPackageDir="C:/temp/output/"
```

Notice that this command does not contain the `/r`.

## Install the unsigned app

To install the app:

- Start an elevated PowerShell command prompt (Search for PowerShell in the start menu, right-click on it then Run as administrator):
- In the folder containing the `.msix` file, execute the following command :

```pwsh
Add-AppPackage -AllowUnsigned ".\MyApp.appx"
```

For more information, see the [official documentation](https://learn.microsoft.com/en-us/windows/msix/package/unsigned-package#install-an-unsigned-package).
15 changes: 15 additions & 0 deletions doc/articles/uno-publishing-windows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
uid: uno.publishing.windows
---

# Publishing Your App for Windows

## Preparing For Publish

## Building your app

Using the Windows App SDK, it's possible to side-load an app using the following:

- [Build an unsigned packaged app](xref:uno.publishing.windows.sideload.packaged.unsigned)
- [Build a signed packaged app](xref:uno.publishing.windows.sideload.packaged.signed)