Deploy asp.net web application - asp.net

I have ASP.NET MVC web application. I need to deploy it which consists of:
1. Changing some of Web.config sections
2. Building under Release configuration
3. Copying to my deployment server (optional)
What are the ways to automate this process?

1. Changing some of Web.config sections
Use the web.config transformation you can implemnt it by modifing the Web.Debug.config and Web.Release.config in your web project
2. Building under Release configuration
3. Copying to my deployment server (optional)
This post should help. Read also this about the publish thing

We use continuous integration via Jenkins/Hudson to build and a task in it to deploy to staging or production that uses msdeploy in a batch script.
For building, our parameters for msbuild for release builds are:
/Target:Clean;Build /Property:Configuration=Release
It does take a while to figure out the msdeploy options but it is worth looking into (it's what Visual Studio is using behind the scenes to do the deploy if you use the GUI-based approach).

In terms of building under release configuration & copying to your deployment server you can use MS-Build alongside a tool like Team City / Team Build to automate the process.
Here is a great post to get yourself up and running: How to use MSBuild to deploy an ASP.NET MVC application

Related

MSBuild MSDeploy from within VS2010 Build Definition

We are currently using Team Foundation Server Build Definitions to build our solution and now I want to add deployment to that. We are using TFS Build servers out of the box for our builds. Currently, we are deploying the web app to our dev integration servers using Web Deploy (MSDeploy) from within VS2010 (Publish on the toolbar). The desire is to move this publish to the build server.
What is the best approach to be able to reuse the MSDeploy mechanism (since it's already in place on IIS) and have the build server take over that task? Can I use MSBuild params or do I need an MSBuild project file? How would I configure the appropriate approach in the Build Definition? It is unclear how to configure a Publish using a Build Definition and MSDeploy.
P.S. I've seen several mentions of MSBuild using MSDeploy with cmd line params, but not in the context of using a Team Explorer Build Definition.
Some links to pages that I've seen, but are incomplete based on my needs:
Creating a Build Definition That Supports Deployment
How to Publish Web with msbuild?
The ALM Rangers' Building Guidance has all the information you are looking for, in particular the chapter "Deployment of Applications and Data Stores".

TFS 2010 Build 2 projects in Solution not transforming web.configs

I have two web applications in a solution which is build using TFS.
The main web application's web.configs are correctly transformed depending on the configuration setting of the build.
In the second web application the project is build and deployed but the web.config is not transformed and all transform web.configs are copied to the publish location.
I.e.:
web.config,
web.dev.config,
web.testing.config
In the build settings > Process > Items to build I have added the solution file. The build says "There are 1 projects for 1 platform and configuration" I am not sure if this is correct. Should it not see both my web applications?
How do I set-up the TFS build to transform both projects web.configs?
Which version of TFS are you using? Have a look here anyway as it might answer you: http://nirajrules.wordpress.com/2011/07/04/integrating-web-config-transformations-with-tfs-build/

Classic asp - How to automate deployment - in continuous integration environment

I've been doing some reading http://vishaljoshi.blogspot.com/2010/11/team-build-web-deployment-web-deploy-vs.html and https://michaelbaylon.wordpress.com/2011/04/13/managing-sql-scripts-and-continuous-integration/ ... etc on automated deployment and continuous integration etc but non of it seems to talk about automated deployment in a classic asp environment and you can't really do proper CI unless you get into automated deployment.
Can MSDeploy deploy a classic asp website? If not ... is it best to just write a build script that copies all the files over to the correct folder and then start up IIS? I've done this using msbuild and the robocopy msbuild extension task. But then how do you handle the different environments (QA, dev, staging, production) there's no web config to put the different connection strings etc ... supposedly msbuild is configuration aware ... but how does that work when there is no web config?
So with all these questions I'm struggling to really move forward with creating a deployment script / module / exe for our classic asp website. Does anyone have any answers / resources / further questions that they can point me in the direction of?
Web Deploy (http://www.iis.net/download/WebDeploy) is the way to go. You just have to customize the deployment script for different environments.
You might find this links helpful:- http://msdn.microsoft.com/en-us/library/ms241740.aspx- "Build" Classic ASP with TFS 2010
MSDEPLOY can deploy anything that can live in IIS. You can create a package from the existing web site, and examine it to see what got packaged. You should be able to use that to determine how to package up your site from sources.
You should even be able to create a Visual Studio project from your sources so that you can use the Web Publishing Pipeline directly. The fact that there is nothing there to compile shouldn't stop you from specifying that your .ASP files are content files.
Checkout using cruisecontrol.net, we use that for our automated deploys along with msbuild and it works great. We are a .Net shop but it's basically the same thing. Cruise Control can run scripts and does handle the web.config / global.asa transformations pretty good. As long as you can script it cruise control could handle it.
Depending on your development environment you might be able to hook it into cruisecontrol. We use TFS and it integrates nicely so when we check items into our different branches (Dev, Main, Stage) it auto deploys the site to the appropriate location.
Deploying to our production environment we use MSbuild to move the code. Since it's in another network location we needed something that could go outside and do any server updates necessary.
http://cruisecontrol.sourceforge.net/

MVC 3 Deploy Automation

I am looking for the most straight forward way to automate the deploy of an MVC 3 application. There is a wealth of information on Stack Overflow already, but much of it seems to be old, and I am not sure what is still relevant to MVC 3.
Here is what I am trying to achieve:
Publish MVC application
Zip files
Copy zip to remote location
It is the “Publish” part of this I am having the most trouble with. Here are my main points of confusion:
How can an automated build be initiated for an MVC 3 app? Do we need to use the AspNetComiler MSBuild Task? I have seen an example of this uses in conjunction with a CSC Task. Are both really needed?
There is a “Build Deployment Package” option in Visual Studio. Can this be initiated with MSBuild? Should this be used instead?
Web Deployment Projects: where do these fit into the picture?
Thanks for any help
I am by far not specialist in application deployment so there might be better ways but here's what I do.
I use Web Deployment Projects to precompile my ASP.NET MVC 3 application
I feed the result of this project to a Setup and Deployment Project
I wrote a custom assembly which is applied to this Setup and Deplyment Project as an Install step and which based on the target IIS version creates App Pool and Virtual Directories.
I ship an MSI to the team responsible for deploying the application. All they need to do is to schedule a task which does an msiexec /u myapp.msi and then msiexec /i myapp.msi.
Remark : in my case all builds are automated in a continuous integration fashion with a Team Foundation Server Build but if you don't have a build server you could also build it manually by running the setup and deployment project which spits an MSI.

ASP.NET Web Application Build Output - How do I include all deployment files?

When I build my ASP.NET web application I get a .dll file with the code for the website in it (which is great) but the website also needs all the .aspx files and friends, and these need to be placed in the correct directory structure. How can I get this all in one directory as the result of each build? Trying to pick the right files out of the source directory is a pain.
The end result should be xcopy deployable.
Update: I don't want to have to manually use the Publish command which I'm aware of. I want the full set of files required by the application to be the build output - this means I also get the full set of files in one place from running MSBuild.
One solution appears to be Web Deployment Projects (WDPs), an add-on for Visual Studio (and msbuild) available that builds a web project to a directory and can optionally merge assemblies and alter the web.config file. The output of building a WDP is all the files necessary to deploy the site in one directory.
More information about Web Deployment Projects:
Announcement on webdevtools MSDN blog for WDP 2008
ScottGu introduction to WDP 2005
The only disadvantage to this solution is the requirement on an add-on which must be available on the build machine. Still, it's good enough for now!
ASP.NET doesn't have real xcopy deployment for new sites. It depends on having a virtual directory/Application in IIS. However, once that virtual directory is created you can use xcopy for updates.
You can Publish Web site..If you want to automate your deployment, you need to use some script.
Have you tried using the aspnet_compiler.exe in your .net framework directory? I'm pretty sure you can create a "deploy ready" version of a web application or web site.
The _CopyWebApplication target on MSBuild will do exactly what you need. The catch is that only the main assembly will be copied to the bin folder and that's why a copy task is needed to also copy any other file on the bin folder.
I was trying to post the sample script as part of this post but wasn't able to.
Please take a look at this article on my blog that describes how to create a MSBuild script similar to the one you need.
Have you tried right clicking the website in Solution Explorer and clicking 'Publish Website'?
Build --> Publish
A dialog box will appear that will guide you through the process.
For the automated building you describe in the update, I would recommend you look into MSBuild and CruiseControl.NET
It depends on how complicated solution you need, you could just use a script and jenkins for example. You can use MSBUild with Jenkins for just deploying to an IIS. And if you got Jenkins other tools is pretty easy to connect into it later on. But if you just want to build, use a script that jenins execute every build that uses MSDeploy and it will work great.
This is how i do it, just to give you a feeling:
Sonarqube uses Gallio, Gendarme, FXcop, Stylecop, NDepths and PartCover to get your metrics and all this is pretty straight forward since SonarQube do this automatically without much configuration.
Here is Jenkins witch builds and get Sonar metrics and a another job for deploying automatically to IIS. I use a simple script one line that calls my MSBuild and wich URL, pass and user.
And Sonarqube, all metrics for my project. This is a simple MVC4 app, but it works great!:
If you want more information can i provide you with a good guide.
This whole setup uses MSBuild, too build and deploy the apps.

Resources