Publishing and Web Deploy

In this lesson, we will learn the various publication options offered by the ASP.NET Core software development kit (SDK), and how to publish our application from within Visual Studio.

A web application can be published to various targets and in several ways. Among them, to a target Web Server through FTP or other protocols, or to a local folder from where it can be moved manually to its target location. The ASP.NET Core software development kit offers a unique, powerful publish command that unifies all types of publications into a unique simple experience.

.NET publish command

All publication types supported by the .NET SDK can be executed with the command below. This must be launched from within the Web project folder:

dotnet publish -p:PublishProfile=MyPublishProfile

Where MyPublishProfile.pubxml is an XML file containing all publish options. Similar files called publish profiles are placed in the Properties/PublishProfiles project folder, as shown below:

Properties
  PublishProfiles
    MyPublishProfile.pubxml 

These files can be created manually, but in this lesson, we will describe how to define them with the Visual Studio publish-wizard.

Once launched, the publish command first compiles the project and all its dependencies, according to the specifications contained in the publish profile. It then publishes its files as per publish-profile specifications.

We can use Visual Studio to create publish profiles, and then publish the application from Visual Studio or with dotnet publish. Publish profiles can be used several times, edited, saved, deleted, and imported from within Visual Studio. During a publish-profile import, we can supply unfilled fields, such as the password and connection string fields.

Once we create a web application folder in IIS or an empty application in the Azure Web App service, we can export a pre-filled publish-profile with all the data to connect with the server and deploy our files in the right folder. The password and connection string fields are usually left empty.

The remainder of the lesson contains the instructions for creating a web application from within Visual Studio and publishing it. We will publish in a local folder, but we will discuss all other publication options. All steps are specific for Visual Studio for MAC. The steps are similar for Visual Studio for Windows.

Creating a test application

Open Visual Studio Instance and click “New”:

Get hands-on with 1400+ tech skills courses.