Asp.Net MVC Publish with Web Deploy Package

  Total Views : 2082
  Comments : 0
  Keywords : Publish / deploy mvc website using web deploy package with example, how to publish mvc web application using web deploy package in visual studio with example

Here we will learn how to publish / deploy mvc web application to iis server using web deploy package in visual studio or use web deploy package option in visual studio to deploy / publish mvc web application in server with example.

Publish Site using Web Deploy Package in Visual Studio

Visual studio 2010 and more versions is having One-Click publish options by using those options we can deploy / publish mvc web application to iis or server directly from visual studio. We have different type of publish options available in visual studio 2012 in that one of option is Web Deploy Package.


If we select web deploy package method then a .zip package will create in our local disk folder. We need to use use this package to deploy using CMD command prompt or we can mail this package to admin team to deploy this .zip package.


Here we will learn step by step process to deploy or publish mvc web application using Web Deploy Package 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 [OrderAppDeploy_WebDeploy_Package] you can enter profile name of your choice.


Create new profile to deploy website using web deploy package


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 "Web Deploy Package". 


To use "Web Deploy Package" for publishing website we need to enter or select Package location and in Site name we need to enter name of site.i.e. like


While choosing Package location select folder location where we want this output to get publish in a folder.


E.g. Here we selected Package location as [C:\Users\sai\Desktop\publish\] it’s a publish name folder on desktop.


After entering package location then enter site name as [Default Web Site/OrderApp]


E.g. First enter default website which is in IIS [Default Web Site] then [/] your Application name.


Enter Details for Web Deploy Package to Publish Website


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] that will be like as shown below


Select File Publish Options in Publish Web Dialog to Deploy Website

Configuring Database section

In case if we have remote connection string, then we need to configure from here for that just select browse button to set remote Connection string. After choosing this option we need to enter all the details of Sql server with Server name, Username and Password. Following is the snapshot which we entered all the details.


Configure Database Remote Connection to Publish Web Application


After completion of adding all database setting now click on OK button. Following is the snapshot after configuring database connection.


After configuring database connection string in publish web dialog


After entering all details related to destination Connection String 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 we are going to publish in folder because it will warp all files in .zip format. Following is the snapshot of Preview dialog window.


Preview to publish website using web deploy package in visual studio


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


Publishing website using web deploy in visual studio


After publishing process is completed just check folder which we selected for publish these files that will be like as shown below.


Publish Files in Folder using Web Deploy Package in Visual Studio

We should able to see these kind of files generated. Now we will deploy these files using command prompt.

Deployment with Command prompt (CMD)

In publish folder there is a file with name [OrderApp.deploy-readme] just open that file to read how to deploy this package.


Now open command prompt as administrator and access directory where our publish folder .zip file is stored like as shown below


Access Publish Folder Path from Command Prompt


Now enter command OrderApp.deploy.cmd /T and click enter it will create a report of what will happen when we actually deploy the package


Execute deploy command in comand prompt to deploy website


After entering command and press enter button it will execute and show the report like as shown below


Display Report After Executing Command in Command Prompt


After checking report now we will deploy package by entering command [OrderApp.deploy.cmd /Y]. Now enter command OrderApp.deploy.cmd /Y and click enter button to publish application.


Publish Application using Deploy Command in Command Prompt


After executing command OrderApp.deploy.cmd /Y it will publish all the files and the execution process will be like as shown below


After publish all the files using command prompt process will be like as shown in image


Now to see where IIS located for people who are new to development or deployment just enter Windows + R from keyboard a new Run window will Pop up inside that type text inetmgr then press enter a new window should pop up of Internet Information Services (IIS) Manager. 


Now we can see the site [OrderApp_Deply] is deployed to IIS inside Default Web Site that will be like as shown below.


After deploy application using web deploy package in visual studio


 This is how we can Web Deploy Package method in visual studio to deploy web application in IIS / Server. 

 Comments (0)

Be the first to give your valuable feedback

Leave a comment

  • Default Tutlane User