Kman
Kman

Reputation: 81

Building a ASP.NET solution from command-line?

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

Upvotes: 8

Views: 15083

Answers (6)

James Lawruk
James Lawruk

Reputation: 31337

Try this in a .bat file, replace v4.0.30319 with the appropriate version:

CD C:\Windows\Microsoft.NET\Framework\v4.0.30319 
msbuild "C:\inetpub\wwwroot\MyWebSite.sln"

Upvotes: 6

ram
ram

Reputation: 11626

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

Upvotes: 1

kͩeͣmͮpͥ ͩ
kͩeͣmͮpͥ ͩ

Reputation: 7846

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">

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

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

built with msbuildprojectname.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.

Upvotes: 1

Jeremy McGee
Jeremy McGee

Reputation: 25200

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.

Upvotes: 0

Chris Fulstow
Chris Fulstow

Reputation: 41872

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.

Upvotes: 1

Related Questions