Asp.Net MVC Publish with File System

Here we will learn how to publish / deploy mvc web application to traged location using file system option in visual studio or use file system publish option in visual studio to deploy / publish mvc web application in given location with example.

Publish Website using File System in Visual Studio

In visual studio 2010 or more version we have different options to publish  / deploy website directly from visual studio those are file system, web deploy, web delopy package, file transfer protocol (ftp).


If we use File System in visual studio it will publish files in given targeted location of our computer which we choosed while publishing then we need copy those files to IIS or mail these files to admin team to deploy.


Here we will learn step by step process to deploy or publish mvc web application using File System option in visual studio. To publish and deploy application here we are going to use simple Internet Application which we already created for deployment with name [OrderApp] like as shown below. mvc sample application to deploy / publish using visual studio


Now let’s build this application and run. Following is the snapshot after running application. mvc web deploy application output


It is working fine. Now we have checked our application and its working fine now let’s publish this Application. Before starting to publish our Application just Run Visual studio as Administrator like as shown below.


Run Visual Studio As Administrator to Publish / Deploy Application

Publishing Application using Visual Studio

To publish application just right click on Project name [OrderApp] and a List of options will appear from that List select [Publish] options like as shown below


Right click project and select publish option to deploy application


After selecting Publish option a new dialog will pop up with name Publish Web like as shown below.


Publish web deploy dialog to deploy mvc web application


In this dialog it will first ask you to create a profile. If you have created profile already then you can select profile from Manage profile just click on Manage profile button a new small dialog box of Edit Web Publish Profiles will appear in that you can see your already created Profile.


Created Web Publish Profiles in Visual Studio Deployment


If you had proper look on Publish Web dialog box you will also find Import button. After clicking on Import button below dialog will appear in this dialog you can Import profile from Azure Website or you can Import from Publish profile file.


Import profile from windows azure website or from publish profile file


We are new to publish this application hence we are going to create a New Profile.

Creating New Profile (stage 1)

To create a New Profile just select [Select or Import a publish profile] dropdown after selecting a [New Profile] item will appear in dropdown list just select that.


Select New Profile from from Select or Import a Publish


After selecting a New Profile, a new dialog box will appear with name [New Profile] asking to enter Profile name.


Enter Profile Name to Create in Publish Web Dialog


Here we entered profile name as [OrderApp_FTP] you can enter profile name of your choice.


Enter Profile Name to Create in File System


After entering profile name just click on OK button then this process will move forward to next stage Connection setting.

Connection setting in Visual Studio (Stage 2)

Now we are going to select a way to publish our application for that we need to move to second step connection and in Publish method we need to select "File System". After selecting Publish method next step is to select Target location for that we created a folder with name [Publish_Site] on our desktop which we are going to select that will be like as shown below.


Mention File Path and Select Publish Method File System to Publish in Visual Studio


After entering all the details click on Next button to Move Forward to next stage of deployment process.

Settings for Deploying Application (Stage 3)

In this Process it will ask for selecting Configuration we have 2 options for this


  1. Debug - Debug is used for debugging.
  2. Release Mode - Release is final deployment.

Here we are going to select Release mode.


File Publish options section


After Selecting Configuration we have File Publish options those like as shown below.


  • If we want to remove additional files at destination, then we need to select this option.
  • If we want to Precompile application during publishing, then we need to select this option.
  • If we want to exclude files from the App_Data folder then we need to select this option.

Here we selected 2 options of File Publish options and selected configuration as Release mode that will be like as shown below


Select File Publish Options in File System to Deploy Website

Configuring Database section

This File System publish method does not support Database publishing. After setting Configuration Click on Next button to Move Forward to next stage of deployment process.

Preview Details (Stage 4)

In this preview we will not get a chance to view files which are getting published using file system method. Following is the snapshot of preview dialog window.


Preview File System Deploy Settings in Visual Studio


After we saw preview option finally click on Publish button to start publishing process.


Publishing Website Status using File System in Visual Studio


After publishing process is completed just view the folder which we selected for publish these files in File System that will be like as shown below. Now we can copy these files to IIS or mail these files to admin team to deploy.


Published Files in Folder using File System in Visual Studio


This is how we can use file system in visual studio to publish web application in IIS or server.

Topics Covered