diff --git a/docs/windows/deployment/publish-cli.md b/docs/windows/deployment/publish-cli.md index fd5261c64b..723d85e0e2 100644 --- a/docs/windows/deployment/publish-cli.md +++ b/docs/windows/deployment/publish-cli.md @@ -15,8 +15,6 @@ ms.date: 10/12/2022 When distributing your .NET Multi-platform App UI (.NET MAUI) app for Windows, you can publish the app and its dependencies to a folder for deployment to another system. You can also package the app into an MSIX package, which has numerous benefits for the users installing your app. For more information about the benefits of MSIX, see [What is MSIX?](/windows/msix/overview) -.NET MAUI currently only allows publishing an MSIX package. You can't yet publish a Windows executable file for distribution. - ## Create a signing certificate You must use a signing certificate for use in publishing your app. This certificate is used to sign the MSIX package. The following steps demonstrate how to create and install a self-signed certificate with PowerShell: @@ -105,7 +103,7 @@ Add the following `` node to your project file. This property gro Replace the `` property value with the certificate thumbprint you previously generated. Alternatively, you can remove this setting from the project file and provide it on the command line. For example: `-p:PackageCertificateThumbprint=A10612AF095FD8F8255F4C6691D88F79EF2B135E`. -The second `` in the example is required to work around a bug in the Windows SDK. For more information about the bug, see [WindowsAppSDK Issue #2940](https://github.com/microsoft/WindowsAppSDK/issues/2940). +The second `` in the example is required to work around a bug in the Windows App SDK. For more information about the bug, see [WindowsAppSDK Issue #3337](https://github.com/microsoft/WindowsAppSDK/issues/3337). ## Publish @@ -115,7 +113,7 @@ To publish your app, open the **Developer Command Prompt for VS 2022** terminal |------------------------------|-------------------------------------------------------------------------------------| | `-f` | The target framework, which is `net7.0-windows{version}`. This value is a Windows TFM, such as `net7.0-windows10.0.19041.0`. Ensure that this value is identical to the value in the `` node in your *.csproj* file. | | `-c` | The build configuration, which is `Release`. | -| `-p:RuntimeIdentifierOverride=win10-x64`
- or -
`-p:RuntimeIdentifierOverride=win10-x86` | Avoids the bug detailed in [WindowsAppSDK Issue #2940](https://github.com/microsoft/WindowsAppSDK/issues/2940). Choose the `-x64` or `-x86` version of the parameter based on your target platform. +| `-p:RuntimeIdentifierOverride=win10-x64`
- or -
`-p:RuntimeIdentifierOverride=win10-x86` | Avoids the bug detailed in [WindowsAppSDK Issue #3337](https://github.com/microsoft/WindowsAppSDK/issues/3337). Choose the `-x64` or `-x86` version of the parameter based on your target platform. > [!WARNING] > Attempting to publish a .NET MAUI solution will result in the `dotnet publish` command attempting to publish each project in the solution individually, which can cause issues when you've added other project types to your solution. Therefore, the `dotnet publish` command should be scoped to your .NET MAUI app project. @@ -173,5 +171,4 @@ Select the **Install** button if you would like to install the app. The following list describes the current limitations with publishing and packaging: -- The published app doesn't work if you try to run it directly with the executable file out of the publish folder. - The way to run the app is to first install it through the packaged _MSIX_ file. diff --git a/docs/windows/deployment/publish-unpackaged-cli.md b/docs/windows/deployment/publish-unpackaged-cli.md new file mode 100644 index 0000000000..bef72421be --- /dev/null +++ b/docs/windows/deployment/publish-unpackaged-cli.md @@ -0,0 +1,57 @@ +--- +title: "Use the CLI to publish Unpackaged apps for Windows" +description: "Learn how to package and publish an unpackaged Windows .NET MAUI app with the dotnet publish command." +ms.date: 10/12/2022 +--- + +# Publish an unpackaged .NET MAUI app for Windows with the CLI + +> [!div class="op_single_selector"] +> +> - [Publish Packaged / MSIX](publish-cli.md) +> - [Publish Unpackaged / EXE](publish-unpackaged-cli.md) + +When distributing your .NET Multi-platform App UI (.NET MAUI) app for Windows, you can publish the app and its dependencies to a folder for deployment to another system. + +## Configure the project build settings + +Add the following `` node to your project file. This property group is only processed when the target framework is Windows and the configuration is set to `Release`. This config section runs whenever a build or publish in `Release` mode. + +```xml + + $(RuntimeIdentifierOverride) + +``` + +The `` in the example is required to work around a bug in the Windows App SDK. For more information about the bug, see [WindowsAppSDK Issue #3337](https://github.com/microsoft/WindowsAppSDK/issues/3337). + +## Publish + +To publish your app, open the **Developer Command Prompt for VS 2022** terminal and navigate to the folder for your .NET MAUI app project. Run the `dotnet publish` command, providing the following parameters: + +| Parameter | Value | +|------------------------------|-------------------------------------------------------------------------------------| +| `-f` | The target framework, which is `net7.0-windows{version}`. This value is a Windows TFM, such as `net7.0-windows10.0.19041.0`. Ensure that this value is identical to the value in the `` node in your *.csproj* file. | +| `-c` | The build configuration, which is `Release`. | +| `-p:WindowsPackageType=None` | Indicates to the publish command that there should be no package. | +| `-p:RuntimeIdentifierOverride=win10-x64`
- or -
`-p:RuntimeIdentifierOverride=win10-x86` | Avoids the bug detailed in [WindowsAppSDK Issue #3337](https://github.com/microsoft/WindowsAppSDK/issues/3337). Choose the `-x64` or `-x86` version of the parameter based on your target platform. | + +> [!WARNING] +> Attempting to publish a .NET MAUI solution will result in the `dotnet publish` command attempting to publish each project in the solution individually, which can cause issues when you've added other project types to your solution. Therefore, the `dotnet publish` command should be scoped to your .NET MAUI app project. + +For example: + +```console +dotnet publish -f net7.0-windows10.0.19041.0 -c Release -p:RuntimeIdentifierOverride=win10-x64 -p:WindowsPackageType=None +``` + +Publishing builds the app, copying the executable to the _bin\\Release\\net7.0-windows10.0.19041.0\\win10-x64\\publish_ folder. In this folder, there's an _exe_ file, and that's the built app. This app can be launched or the entire folder can be copied to another machine and launched there. + +One important distinction from a packaged app is that this will _NOT_ include the .NET runtime in the folder. This means that the app will require the .NET runtime to first be installed on the machines that will eventially run the app. To ensure the app also contains _all_ the runtime components, the `--self-contained` argument can be provided when publishing. +For example: + +```console +dotnet publish -f net7.0-windows10.0.19041.0 -c Release --self-contained -p:RuntimeIdentifierOverride=win10-x64 -p:WindowsPackageType=None +``` + +For more information about the `dotnet publish` command, see [dotnet publish](/dotnet/core/tools/dotnet-publish).