You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aspnetcore/blazor/host-and-deploy/index.md
+26-4Lines changed: 26 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -28,12 +28,22 @@ Apps are published for deployment in Release configuration.
28
28
# [Visual Studio](#tab/visual-studio)
29
29
30
30
1. Select the **Publish {APPLICATION}** command from the **Build** menu, where the `{APPLICATION}` placeholder the app's name.
31
-
1. Select the *publish target*. To publish locally, select **Folder**.
32
-
1. Accept the default location in the **Choose a folder** field or specify a different location. Select the **`Publish`** button.
31
+
1. Select the *publish target*. To publish locally, select **Folder**. Select **Next**.
32
+
1. When publishing locally, accept the default folder location or specify a different location. Select **Finish** to save the profile. Select **Close**.
33
+
1. To clean the target's publish folder prior to publishing the app, select **Show all settings**. Select **Settings** > **File Publish Options** > **Delete all existing files prior to publish**. Select **Save**.
34
+
1. Select the **Publish** button.
33
35
34
-
# [.NET CLI](#tab/net-cli)
36
+
# [Visual Studio Code and .NET CLI](#tab/visual-studio-code-dotnet-cli)
35
37
36
-
Use the [`dotnet publish`](/dotnet/core/tools/dotnet-publish) command to publish the app with a Release configuration:
38
+
Open a command shell to the project's root directory.
39
+
40
+
Use the [`dotnet publish`](/dotnet/core/tools/dotnet-publish) command to publish the app:
41
+
42
+
```dotnetcli
43
+
dotnet publish
44
+
```
45
+
46
+
Prior to .NET 8, the default publish configuration is `Debug`. When publishing an app that targets .NET 7 or earlier, pass the `-c|--configuration` option to the command with "`Release`" to publish in `Release` configuration:
37
47
38
48
```dotnetcli
39
49
dotnet publish -c Release
@@ -43,6 +53,18 @@ dotnet publish -c Release
43
53
44
54
Publishing the app triggers a [restore](/dotnet/core/tools/dotnet-restore) of the project's dependencies and [builds](/dotnet/core/tools/dotnet-build) the project before creating the assets for deployment. As part of the build process, unused methods and assemblies are removed to reduce app download size and load times.
45
55
56
+
## Empty the target publish folder
57
+
58
+
When using the [`dotnet publish`](/dotnet/core/tools/dotnet-publish) command in a command shell to publish an app, the command generates the necessary files for deployment based on the current state of the project and places the files into the specified output folder. The command doesn't automatically clean the target folder before publishing the app.
59
+
60
+
To empty the target folder automatically before the app is published, add the following MSBuild target to the app's project file (`.csproj`) under the root `<Project>` element:
0 commit comments