4

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Simon Steele
  • 11,558
  • 4
  • 45
  • 67

9 Answers9

5

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:

  1. Announcement on webdevtools MSDN blog for WDP 2008
  2. 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!

Simon Steele
  • 11,558
  • 4
  • 45
  • 67
  • This is exactly what we use to prepare a release or test copy of the web application/site for users. – icelava Dec 31 '08 at 02:59
2

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.

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
  • Right, and I have a powershell script that installs the website providing all the files are present in the right place. When I want to update the website I again need all the files and can xcopy deploy those. – Simon Steele Sep 10 '08 at 21:10
  • When you update the site, what is the difference between publishing the site through VS and running your script? – GEOCHET Sep 10 '08 at 21:12
  • I am developing web sites that are used outside of our corporate intranet - i.e. I need to take the site to a customer and install it there, or have it packaged ready for that. I also want to install an official build of the site from the build server. – Simon Steele Sep 10 '08 at 21:15
1

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.

JCallico
  • 1,446
  • 18
  • 25
1

You can Publish Web site..If you want to automate your deployment, you need to use some script.

Gulzar Nazim
  • 51,744
  • 26
  • 128
  • 170
1

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.

Min
  • 2,975
  • 1
  • 19
  • 24
0

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.

Jonathan
  • 369
  • 3
  • 9
0

Have you tried right clicking the website in Solution Explorer and clicking 'Publish Website'?

GEOCHET
  • 21,119
  • 15
  • 74
  • 98
  • Yes, I can publish the website like that as a manual step, but I want the result of building the solution to place the deployment items in a directory with the rest of the solution build results. This also means a run of msbuild on the build machine gets me what I want. – Simon Steele Sep 10 '08 at 21:08
  • If you want an automated build script, you should update your question. – GEOCHET Sep 10 '08 at 21:10
0

Build --> Publish

A dialog box will appear that will guide you through the process.

NakedBrunch
  • 48,713
  • 13
  • 73
  • 98
0

For the automated building you describe in the update, I would recommend you look into MSBuild and CruiseControl.NET

GEOCHET
  • 21,119
  • 15
  • 74
  • 98
  • Hi Rich, I'm using MSBuild already to build the project and this is triggered on every check-in by an internal system a little like CCNet. The problem is that only the assembly from the project is placed in the output directory - no .aspx files or other content - I want the content too. – Simon Steele Sep 10 '08 at 21:21