I am trying to replicate the exact functionality of this dialogue in Visual Studio 2008 in a build script: alt text http://i41.tinypic.com/1osl1f.png
This is an ASP.NET web site, not a web application.
I have Googled around this and turned up quite a bit of stuff involving MSBuild, but this all seems to concern solutions laid out as ASP.NET Web Applications:
http://www.driebier.net/post/Using-MSBuild-to-deploy-visual-studio-2005-web-applications.aspx http://blog.donnfelker.com/post/TFS-Build-Not-Publishing-Web-Applications.aspx
This article seems to be relevant to ASP.NET Web Sites, but I find that I'm getting an error when trying to build using those suggestions:
C:\dev\T&A>msbuild /t:_CopyWebApplication /property:OutDir=c:\temp\taweb\ /prope rty:WebProjectOutputDir=c:\temp\taweb\ Microsoft (R) Build Engine Version 3.5.30729.1 [Microsoft .NET Framework, Version 2.0.50727.3074] Copyright (C) Microsoft Corporation 2007. All rights reserved. Build started 22/04/2009 11:50:42. Project "C:\dev\T&A\TAWeb.sln" on node 0 (_CopyWebApplication target(s)). Building solution configuration "Debug|.NET". C:\dev\T&A\TAWeb.sln : error MSB4057: The target "_CopyWebApplication" does not exist in the project. Done Building Project "C:\dev\T&A\TAWeb.sln" (_CopyWebApplication target(s)) -- FAILED. Build FAILED. "C:\dev\T&A\TAWeb.sln" (_CopyWebApplication target) (1) -> C:\dev\T&A\TAWeb.sln : error MSB4057: The target "_CopyWebApplication" does n ot exist in the project. 0 Warning(s) 1 Error(s) Time Elapsed 00:00:00.06
The solution I'm trying to publish (inherited, not my own) doesn't have .csproj files (where I could import the _CopyWebApplication target from C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets)
Perhaps this is a Visual Studio 2005/2008 difference?
Anyway, I feel that I'm going down the wrong path there.
Essentially I just need to achieve exactly what the above dialogue does, but from the command line.
Thanks very much
Personally I use buildbot which runs commands for me, I had to create a VBS script which performs the upload for me.
I installed WinSCP to do the ftp work and then just scripted the upload:
To pre-compile the website from a command line I do the following, however I do this on the web server rather than before uploading it:
Here's a little PowerShell script that builds a solution, then publishes a web project from it.
The MSBuild is for .Net 3.5, so change to "\v4.0\" if needed.
The "ResolveReferences" must come before "_CopyWebApplication" otherwise dependencies go missing.
The example paths given here build to:
I think you are looking for the AspNetCompiler task
The error you received (C:\dev\T&A\TAWeb.sln : error MSB4057: The target "_CopyWebApplication" does not exist in the project) is due to two issues. First: the target _CopyWebApplication must be called on a WebApplication project file, not a solution. Second: a website does not have a project file, WebApplications have project files.
The _CopyWebApplication target only applies to publishing a WebApplication project. Use the AspNetCompiler MSBuild task must be used to publish a website.
When you publish a website in visual studio 2008, the second line of output is "Pre-compiling Web Site". The options visual studio displays for publishing a website map directly to options for the AspNetCompiler and Aspnet_compiler.exe.
Though I'm not the first here to say "use AspNet_compiler", I thought describing the reasons why may be helpful. On a side note, I think the AspNet_compiler can be used to publish a webapp but I need to do some more testing.
I use bat file using msbuild.exe (.net 3.5, vs 2008) for "publish" my website (vbproj) in a folder.
There's nothing magical about the "Publish..." feature that you couldn't recreate on your own, especially since you are targeting a network file share.
At it's core, all it's doing is copying your files from one place to another. Using NAnt, you can pull this off with a copy task or you can use an exec task to call xcopy If you're using a build tool other than NAnt, I'm sure there is support for similar tasks.
If you want to leave your raw code and debugging information behind, you can exclude files that end with .cs or .pdb. Both NAnt copy and xcopy provide easy ways to do this.