Programmatic Publish for an ASP.NET Project

by breeve 19. November 2009 16:07

I recently needed to automate an ASP.NET project build so that it copies itself to a directory. This is accomplished in Visual Studio 2008 by right clicking the ASP.NET project and selecting Publish. For ASP.NET projects, the Publish command copies all files needed for the site.

After searching some, I found this can be done by using msbuild. Below is my solution that copies all files needed to C:\Data\Projects\TestDeploy. It invokes msbuild to build the web application then uses an existing task called _CopyWebApplication to copy all the files over.

msbuild /t:Build;_CopyWebApplication /p:Configuration=Release
/p:OutDir=C:\Data\Projects\TestDeploy\bin\
/p:WebProjectOutputDir=C:\Data\Projects\TestDeploy
C:\src\Branches\HOA\HomeOwners.Mvc\HomeOwners.Mvc.csproj

Note that this solution does not precompile the site. To precompile, use aspnet_compiler.

Tags:

Software

Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen

About Me

I am a Software Engineer with 9 years experience developing and releasing software products. I started developing in C/C++ then moved into .NET and C# for the last 7 years and have tech lead multiple projects. I have developed products in Windows Forms, ASP.NET/MVC, Silverlight, and WPF. I currently reside in Austin, Texas.

Currently Reading

Pet Project

Created ASP.NET MVC forum originally targeting home owner associations but now in use by an investor group.

http://vtssinvestor.com/