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

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/

Related

Is it possible to precompile an ASP.NET Web Forms Project on a build server?

ASP.NET Web Forms apps have a large startup cost on the first request as they need to compile the views code (.ascx, .aspx, etc). We have to deploy these projects to several servers, which requires priming each of them so that the first users to hit certain areas of the site don't have a bad response time. Today this is a manual process, and we're making it automated by running aspnet_compiler.
Is is possible to run aspnet_compiler on the build server and deploy its output so that we do not have to run it on each web server we're deploying to?
Bonus Question: When we specify a target directory with the targetdir option in aspnet_compiler, how does IIS know where to look for the compiled files? i.e. Where is that information stored?
The project in question is a Web Application project (not a Web Site project).
There is an option in Visual Studio's Publish dialogue which may be what you want.
I've not used it to see if it actually has the effect you want, but there's several options in Configure for it. You may be able to do what you want with that.
(P.S.: This is an ASP.NET Web Forms Project as well, in VB.NET. Though the language is irrelevant.)
Also, according to this MSDN article you can add the -u and -v switches to the aspnet_compiler to get it to precompile the views for updating.
You may also want to look at this MSDN article as well, as it describes a scenario similar to yours. Especially the Compiling an Application for Deployment section, which states:
You compile an application for deployment (compilation to a target location) by specifying the targetDir parameter. The targetDir can be the final location for the Web application, or the compiled application can be further deployed.
Essentially, you might be able to run this command on your build server, and then distribute your binaries as needed.

Deploy asp.net web application

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

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.

How to include config for IIS modules in web.config without breaking app on server that don't have the module installed

I want to include configuration for the Application Warmup module for IIS 7.5 in my application's web.config file ( an <httpWarmup> element inside <system.webServer>)
This works fine when the module is installed, but if I want to deploy the application to a server without the module installed (e.g. IIS Express) I get
HTTP Error 500.19 - Internal Server
Error
The requested page cannot be
accessed because the related
configuration data for the page is
invalid.
Can this be done? Is there a setting to make IIS ignore extra elements in <system.webServer> that it doesn't recognise?
Thanks
If you're using Visual Studio 2010 then you can use the web.config transformation feature. Using transformations you can, in combination with the website 'Publish' tool, transform your web.config and add/remove settings depending on whether you're doing a debug or release build.
For more information see:
Web.config Transformation Syntax for Web Application Project Deployment
How to: Transform Web.config When Deploying a Web Application Project
Scott Hanselman has a great demo of this feature:
Web Deployment Made Awesome: If You're Using XCopy, You're Doing It Wrong
This works with ASP.NET 2.0 and 4.0.
If you're still using Visual Studio 2008 then it's still possible to achieve this.
First off is to use a brute force approach and maintain multiple web.config files. When you build the project in VS you use a pre-built event swap in the correct web.config file. I've used this technique before but Scott Hanselman (as always) has a nice worked example:
Managing Multiple Configuration File Environments with Pre-Build Events
If you're using MSBuild directly then you could use a build task to modify the web.config files. There's an extension library available from the MSBuild Community Tasks Project which provides additional extensions to MSBuild to make these tasks easier. The XmlMassUpdate task is probably the task you'd want to use. I'll be honest and admit that I'm only scratching the surface of MSBuild at the moment and haven't actually tried this, but (and I don't mean this in a LMGTFY way) googling XmlMassUpdate returns a rich seam of useful looking hits.

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