.Net Framework 2.0 emerged with the very powerful and sophisticated compilation architecture here is a very brief description how we can compile a website in .Net 2.0 using MSBuild (Build tool shipped with .Net Framework 2.0)



Prerquisites:
     > Understading of Build tool, Build Tasks and Properties
     > Compilation Modes in .Net Framework 2.0

Those who are not aware of Build Tool, can follow the below given steps to compile Asp.Net 2.0 Website

1. Create a file with extention .msbuild with the following xml, replace the WebsiteName, PrecompiledAssembliesPath and BuildDirectory with your values.  

<Project DefaultTargets="Main" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup>
 <WebsiteName>MyWebSite</WebsiteName> 
 <PrecompiledAssembliesPath>E:\temp\Project\Build\</PrecompiledAssembliesPath>
  <BuildDirectory>E:\temp\Project\</BuildDirectory>
  </PropertyGroup>
  <Target Name="Main">
 <AspNetCompiler 
         VirtualPath="/$(WebsiteName)"
     PhysicalPath="$(BuildDirectory)"
     TargetPath="$(PrecompiledAssembliesPath)"
     Force="true"
     Debug="true"
     Updateable="true"
 />
  </Target>
</Project>

References: http://msdn2.microsoft.com/en-us/library/7z253716.aspx

2. Run Following command from command line from .Net 2.0 Command prompt (MSBuild.exe is available in..     
    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727)
    MSBuild.exe C:\Progra~1\MSBuild\temp.msbuild

Actually the compilation is being done through aspnet_compiler.exe, which is called by AspNetCompiler task in MSBuild script. the task attributes like PhysicalPath, Debug, Updateable are mapped with aspnet_compiler.exe command line arguments inturn.

I hope this article covers enough things around MSBuild and .Net 2.0 compilation. feel free to ask for any clarification.

 

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Feedback

# re: Website Compilation in .Net Framework 2.0 with MSBuild Script

IS there any possiblity of compiling multiple web projects from a solution file in aspnet_Compiler.exe using MSBuild Script? 3/31/2010 3:32 PM | Saravanan

# re: Website Compilation in .Net Framework 2.0 with MSBuild Script

Hi,

Yes its pretty easy. in above example we have only target "main" to compile a project.

you can create mutiple targets with different names and call them in main target. e.g.

---------------------------------------------------
<target name="main">
<CallTarget Targets="TargetA"/>
<CallTarget Targets="TargetB"/>
</target>

<Target Name="TargetA">
<Message Text="Building Project-A..." />
</Target>
<Target Name="TargetB">
<Message Text="Building Project-B..." />
</Target>
---------------------------------------------------

Hope this suffice to answer your query :)
4/1/2010 9:33 PM | Narendra Tiwari

# re: Website Compilation in .Net Framework 2.0 with MSBuild Script

With this approach for each folder in the website one seperate dll is created, is there a way to have reduce the number of dlls per website.
Thanks,
Murali
9/16/2010 7:12 PM | Murali

Post a comment





 

 

News

Employers
Soppa Group India
iSmart Panache Inc
R Systems Internationals Ltd
Technovate eSolutions Pvt Ltd
The contents of this blog are my personal opinion and do not represent in any way the view of my employer.
These postings are provided "AS IS" with no warranties, and confer no rights.

Google PR™ - Post your Page Rank with MyGooglePageRank.com

Archives

Post Categories

Image Galleries

Articles & Magazines

ASP.Net 2.0 Compilation

ASP.Net, Blogs I refer...

Atlas

Dost

Drivers and Software Download

Garhwal

Travel Domain

WSS and WebParts

Syndication: