Alex Rivera | Logout

How do I compile an ASP.Net MVC project using MSBuild

Asked 2010-02-03T21:41:56.227
14

How do I compile an ASP.Net MVC project using MSBuild? We use a Continuous Integration server to compile and deploy our applications. To keep things simple I created an MVC 1.0 project in VS2008. I immediately created an MSBuild script file to compile it. I did not change any code in the project. The MSBuild script contained the following target.

   <AspNetCompiler
      VirtualPath="/"
       PhysicalPath="C:\Development\mvc1\"
        TargetPath="c:\publish\xxx"
        Force="true"
        Debug="false" 
 Updateable="true"

The MVC project sln file is contained in the c:\development\mvc1\ directory. I am running XP/Pro.

I am receiving an error ASPCONFIG: it is an error to use a section registered as allowDefintion='MachineToApplication' beyond application level.. I removed the authenication mode, membership provider, etc. from the web config file until I finally saw a different error message. I am now receiving an error message saying that the file '/views/shared/site.master' does not exist.

What is going on? Thanks in advance for your help!

Am I using the wrong MSBuild command?

Edit
Report

1 Answer

0

You could use NAnt which has a "msbuild" task in it that will just do it for you. NAnt is a great way to go for CI builds.

The NAnt home page The NAnt Contrib home page The MSBuild task reference from NAnt Contrib

...the contrib library adds some great functionality that the vanilla NAnt doesn't have. It is very simple. I've included a snippet of my .build file here so you can see how I've used it:

<property name="DeployDestination" value="\\MyTestServerName\DestinationFolder"/>
<property name="Solution.Configuration" value="Debug" overwrite="True" />
<property name="nant.settings.currentframework" value="net-3.5" />
<if test="${WebContentDestination=='Production'}">
    <property name="DeployDestination" value="\\MyProductionServer\DestinationFolder"/>
</if>

...<snip>

<target name="Build">
    <msbuild project="SolutionFileName.sln">
        <arg value="/p:Configuration=${Solution.Configuration}" />
    </msbuild>
</target>

<target name="Deploy">
    <copy todir="${DeployDestination}" flatten="true" >
        <fileset>All files to copy</fileset>
    </copy>
</target>
answered 2010-02-03T21:53:30.147

Your Answer