Publishing our native web application

Installing and/or configuring a production-ready web server, such as Internet Information Services (IIS) or Apache, can be a very complex task depending on a number of things that we can't address now, as they would easily bring us far beyond the scope of this book.

To keep things simple, we'll just assume that we already have access to an up and running, physical or virtualized Windows Server machine featuring a running IIS instance (we'll call it web server from now on) that we can configure to suit our needs. Ideally, we'll be able to do that via a dedicated management interface such as Remote Desktop, IIS Remote Configuration, Plesk, or any other remote administration mechanism made available by our web farm and/or service provider.

Note

Windows 2008 R2 (or newer) and IIS 7.5 (or above) will be required to host a .NET Core web application, as stated by the official Microsoft publishing and deployment documentation available at the following URL: 

https://docs.asp.net/en/latest/publishing/iis.html

Last but not least, we'll also assume that our web server provides FTP-based access to the /inetpub/ folder that we can use to publish our web projects.

Tip

If we're facing a different scenario, it could be advisable to skip this chapter entirely and follow the instructions given by our chosen web hosting provider instead.

Creating a Publish profile

The most convenient way to deploy a web-based project in Visual Studio is creating one or more Publish profiles. Each one of them is basically an XML configuration file with a .pubxml extension that contains a set of deployment-related information, most of which depends on the server/target we're deploying our application into, Azure, FTP, filesystem and more.

We can easily set up one or more Publish profile files using the Publish profile wizard. As soon as we have at least one ready, we'll be able to execute it with a single mouse click and have our application published.

To open the Publish profile wizard, right-click on the project's root node (OpenGameListWebApp in our case) and select the Publish... option from the contextual menu. A pop-up window should open showing the following welcome screen:

Creating a Publish profile

File System Publish profile

Among the various available profiles, the easiest to configure is the one that builds everything into a dedicated folder within our local File System. To create it, follow these steps:

  1. Select the Custom publish target.
  2. Give a suitable name to the profile, such as Production-FileSystem.
  3. Select the File System publish method.
  4. When prompted for a Target Location, specify the path of the folder that will contain the published application. Visual Studio will suggest a path located within the application's /bin/Release/ subfolder. However, it's strongly advisable to change it and to choose an external directory instead.
  5. Set Configuration to Release.
  6. Set the Target Framework accordingly to what we used for our project (.NET Framework 4.6.1 in our example).

We can then click on the Publish button to start the publishing process. Once done, we'll have to manually upload the generated contents to the web server.

FTP Publish profile

As a viable alternative we can also create a Publish profile that will automatically upload our web project to our web server using a properly configured FTP connection endpoint: we will then link the remote destination folder to a new website project using IIS.

Note

As we said earlier, we're doing all that assuming that we have a web server accessible through FTP, since it's one of the most common deployment scenarios. If that's not the case, we might as well skip this paragraph and configure a different Publish profile.

We already know how to launch the wizard. Right-click on the project's root node and select Publish. Wait for it to start, then do the following:

  1. Select the Custom publish target.
  2. Give a suitable name to the profile, such as Production-FTP.
  3. Select the FTP publish method.
  4. When prompted for a Server, specify the FTP server URL, such as ftp.your-ftp-server.com. In the Site Path option, insert the target folder from the FTP server root, such as /OpenGameList/.
  5. Set the Passive Mode, Username, and Password according to our FTP server settings.
  6. Set Configuration to Release.
  7. Set the Target Framework accordingly to what we used for our project (.NET Framework 4.6.1 in our example).

Right after that, the wizard's Connection tab should eventually look not too different from the following screenshot:

FTP Publish profile

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset