Skip to content

Commit b45b267

Browse files
authored
Improve publishing guidance
1 parent db376e6 commit b45b267

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

  • aspnetcore/blazor/host-and-deploy

aspnetcore/blazor/host-and-deploy/index.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ Apps are published for deployment in Release configuration.
2828
# [Visual Studio](#tab/visual-studio)
2929

3030
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. Accept the default folder location or specify a different location. Select **Finish** and select **Close**.
33+
1. To clean the publish folder prior to publishing the app, select **Show all settings** followed by **Settings** > **File Publish Options** > **Delete all existing files prior to publish**, followed by **Save**.
34+
1. Select the **`Publish`** button.
3335

3436
# [.NET CLI](#tab/net-cli)
3537

@@ -39,6 +41,16 @@ Use the [`dotnet publish`](/dotnet/core/tools/dotnet-publish) command to publish
3941
dotnet publish -c Release
4042
```
4143

44+
The `dotnet publish` 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.
45+
46+
To empty the target folder automatically before the app is published, add the following MSBuild target to the app's project file:
47+
48+
```xml
49+
<Target Name="_RemovePublishDirBeforePublishing" BeforeTargets="BeforePublish">
50+
<RemoveDir Directories="$(PublishDir)" Condition="'$(PublishDir)' != ''" />
51+
</Target>
52+
```
53+
4254
---
4355

4456
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.

0 commit comments

Comments
 (0)