-
Notifications
You must be signed in to change notification settings - Fork 256
Create Unpackaged publish docs for Windows #1686
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
Closed
+59
−5
Closed
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4e87e8f
Create publish-unpackaged-cli.md
mattleibow 7a56d0c
Update publish-unpackaged-cli.md
mattleibow bfc368d
Update publish-cli.md
mattleibow afd5778
Update publish-unpackaged-cli.md
mattleibow e3d8497
Update publish-cli.md
mattleibow 2c9aa49
Update publish-unpackaged-cli.md
mattleibow 25e181d
Update publish-unpackaged-cli.md
mattleibow 40fa77b
Update publish-unpackaged-cli.md
mattleibow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| --- | ||
| 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 | ||
|
|
||
| The project file is a good place to put Windows-specific build settings. You may not want to put some settings into the project file, such as passwords. The settings described in this section can be passed on the command line with the `-p:name=value` format. If the setting is already defined in the project file, a setting passed on the command line overrides the project setting. | ||
|
|
||
| Add the following `<PropertyGroup>` 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 | ||
| <PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows' and '$(RuntimeIdentifierOverride)' != ''"> | ||
| <RuntimeIdentifier>$(RuntimeIdentifierOverride)</RuntimeIdentifier> | ||
| </PropertyGroup> | ||
| ``` | ||
|
|
||
| The `<PropertyGroup>` 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 `<TargetFrameworks>` 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`<br>- or -<br>`-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). | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.