views:

206

answers:

6

How can I build an ASP.NET web application from the command line?

A: 

Take a look at the devenv.exe /Build switch, you give it a solution file to build, e.g.

devenv.exe "C:\Documents and Settings\someuser\MySolution.sln" /build DEBUG

If you have more complex build requirements then look into MSBuild.

cxfx
A: 

To build a solution directly,

msbuild mysolution.sln

You'll find MSBuild in the Microsoft.NET folder in your Windows directory.

You may also want to pre-compile your Web site. Instructions for that are on MSDN here. If you use the Web Deployment project node (detailed at the bottom) then the deployment will happen automatically when you run msbuild on the solution file.

Jeremy McGee
A: 

This is a round about way to do it, but you can use the MSBuild task as part of an msbuild project:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;

<ItemGroup>
  <Solutions Include="*.sln" />
</ItemGroup>

<Target Name="Build"   >
  <MSBuild BuildInParallel="true" Projects="@(Solutions)" RebaseOutputs="true"  />
</Target>

built with msbuild projectname.proj from the command line.

This may seem like overkill, but you can then add extra stuff into the project (like restarting websites, zipping files, Virtual machine control even!, code coverage) that can help you setup and test the project.

David Kemp
A: 

Would it work to let IIS build it for you? "Web site" projects don't need to be pre-built.

RickNZ
A: 

As dumb as I might look, I have used "aspnet_compiler.exe" for compiling/deploying projects

ram