Replicate VS2008 "Publish Web Site" from command line
The following command duplicates the Publish Web Site dialog with default settings.
Command for Publish Web Site with Default Settings
aspnet_compiler -nologo -v / -p "C:\WebSite1" -u "C:\TargetPath"
Reference
1) See Community Content titled You want Publish a site but you have not Visual Studio then... at http://msdn.microsoft.com/en-us/library/20yh9f1b(classic).aspx.
- Microsoft Visual Studio 2005 > Visual Studio 2005 Command Prompt
- Microsoft Visual Studio 2008 > Visual Studio 2008 Command Prompt
- Microsoft .NET Framework SDK v2.0 > SDK Command Prompt
2) See "ASP.NET Compilation Tool (Aspnet_compiler.exe)" at http://msdn.microsoft.com/en-us/library/ms229863.aspx.
3) Following excerpt from Walkthrough: Deploying an ASP.NET Web Application Using XCOPY at http://msdn.microsoft.com/en-us/library/f735abw9.aspx
As an alternative to using the XCOPY command-line tool, which is supported by all versions of the .NET Framework, you can use the new .NET Framework 2.0 tool located at %SystemRoot%\Microsoft.NET\Framework\version 2 or later\Aspnet_compiler.exe to compile and deploy your Web application. For more information, see ASP.NET Compilation Tool (Aspnet_compiler.exe).
4) Following excerpt from How to: Precompile ASP.NET Web Sites for Deployment at http://msdn.microsoft.com/en-us/library/ms227976.aspx.
If your Web site is not an Internet Information Services (IIS) application and therefore has no entry in the IIS metabase, used the following value for the -v switch.
aspnet_compiler -p physicalOrRelativePath -v / targetPath
In this case, the physicalOrRelativePath parameter refers to the fully qualified directory path in which the Web site files are located, or a path relative to the current directory. The period (.) operator is allowed in the physicalOrRelativePath parameter. The -v switch specifies a root that the compiler will use to resolve application-root references (for example, with the tilde (~) operator). When you specify the value of / for the -v switch the compiler will resolve the paths using the physical path as the root.
I think you are looking for the AspNetCompiler task
<Target Name="PublishToIIS" DependsOnTargets="Publish"> <AspNetCompiler VirtualPath="$(IISVirtualPath)" TargetPath="$(IISTargetPath)" PhysicalPath="$(MSBuildProjectDirectory)/trunk/InternalAppCS/Web.UI/" Force="true" Debug="$(IISDebug)" /></Target>
This "magic" combination does what you're looking for. )It only took two days to get the right combination for my project.) The key is to include the _CopyWebApplication target and the ResolveReferences target.
msbuild "/t:_CopyWebApplication;ResolveReferences;publish" /p:OutDir="C:\inetpub\wwwroot\[appname]\bin\" /p:WebProjectOutputDir="C:\inetpub\wwwroot\[appname]" c:\directory\[appname].csproj