views:

2990

answers:

4

Hi folks,

if i decide to use the 'publish' option for my ASP.NET website, instead of a Web Deployment Project, can i do custom msbuild things? Or do i need to stick with WDP's if i want to do custom msbuild stuff during compile/deployment.

+4  A: 

I think of the publish option as a part of the VS.NET toolset for developers to use to publish web sites on dev machines. It isn't really built to be a real deployment.

If you need custom actions, a Web Deployment Project would be more suited to a real deployment that multiple people other than the developer run regularly and that you want created with each build.

I would also look at three other options:

  • PowerShell: A good way to script against IIS, set up websites, etc. You can even build cmdlets from OO code (like C#) that your script can call. Many professional IT firms use it to deploy big web sites.

  • MSDeploy: A new deployment tool for websites that can replicate a vroot over several servers. Very good for having your golden image and then blasting it out to various places.

  • C# application: If you are a more advanced developer, you can always write your own application that xcopies files (via Process) and uses WMI to configure IIS. Harder, but you have complete control.

Geoff Cox
+1  A: 

It looks like you can customize the Publish task through the _CopyWebApplication MSBuild target. Or you can at least create a batch file that will call that target, which you can customize.

More details here and here.

sliderhouserules
+1  A: 

You can use custom MSBuild options. In fact, you can execute MSBuild on a sln file configured to publish as a website, and then copy the precompiled website files to a webserver. We do that internally using Cruise Control.net from Thoughtworks.

The sln file contains info about where the precompiled website will be located:

Release.AspNetCompiler.VirtualPath = "/PrecompiledWeb"
Release.AspNetCompiler.PhysicalPath = "..\Web\"
Release.AspNetCompiler.TargetPath = "..\..\PrecompiledWeb\"
Release.AspNetCompiler.Updateable = "true"
Release.AspNetCompiler.ForceOverwrite = "true"
Release.AspNetCompiler.FixedNames = "true"
Release.AspNetCompiler.Debug = "False"
MartinHN
+1  A: 

We don't use publish to deploy our web projects, but we used to use Web Deployment Projects. When we switched to Visual Studio 2008, we ran into a bunch of problems with them, so we got rid of them.

What I can tell you is that we were able to replace the WDP functionality we were using with aspnet_merge.exe. We use a combination of msbuild and aspnet_merge.exe in a script to get our deployments done.

Greg
Wow. I hadn't even heard of aspnet_merge until you mentioned it. Here are the docs: http://msdn.microsoft.com/en-us/library/bb397866.aspx
Dan Esparza